asp.net获取访问者ip地址的函数
2024-09-06 02:08:09
/// <summary>
/// 获取IP地址
/// </summary>
public static string IPAddress
{
get
{
string userIP;
// HttpRequest Request = HttpContext.Current.Request;
HttpRequest Request = HttpContext.Current.Request; // ForumContext.Current.Context.Request;
// 如果使用代理,获取真实IP
if (Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != "")
userIP = Request.ServerVariables["REMOTE_ADDR"];
else
userIP = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (userIP == null || userIP == "")
userIP = Request.UserHostAddress;
return userIP;
}
}
最新文章
- scrapy的scrapyd使用方法
- Java多线程18:线程池
- 计算字符串高度 iOS
- AxureRP7.0教学大纲Tutorial directory
- Vue.2.0.5-Render 函数
- Oracle正则表达式之匹配网址
- java使用字节流和字符流实现文件复制
- codeforces 862B B. Mahmoud and Ehab and the bipartiteness
- [HNOI2008] GT考试
- Expression Trees 参数简化查询
- Servlet CDI example analysis
- 3D游戏的角色移动和旋转
- 算法笔记 3.2 codeup1934 找X
- how to generate an analog output from a in-built pwm of Atmega 32AVR microcontrloller?
- syslinux 和 grub
- Windows Server 2012设置WinDbg Kernel Debugging Local
- 【2017.12.05 智能驾驶/汽车电子】转载:如何成为一名无人驾驶工程师 By刘少山
- Java之深入JVM(6) - 字节码执行引擎(转)
- idea中dependencies中总是有红色波浪线(缺少dependency)问题
- redis——持久化方式RDB与AOF分析