最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
ASP.NET 获取客户端IP方法
时间:2022-06-25 07:13:22 编辑:袖梨 来源:一聚教程网
| 代码如下 | 复制代码 |
|
stringrequestClientIpAddress = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; if(string.IsNullOrEmpty(requestClientIpAddress)) requestClientIpAddress = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]; if(string.IsNullOrEmpty(requestClientIpAddress)) requestClientIpAddress = HttpContext.Current.Request.UserHostAddress; | |
经过测试 存在负载均衡的时候 ,HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] 取出的是真实的客户端 IP地址 ,而HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"] 和 HttpContext.Current.Request.UserHostAddress 取出的是被分配的保留地址
相关文章
- 全国计算机二级考试报名入口官网-官方直达路径 12-16
- 洛克王国世界炼金有什么配方 12-16
- 罗马仕充电宝召回型号有哪些-如何查看你的罗马仕充电宝是否在召回范围 12-16
- 原神赛索斯怎么全面培养 12-16
- 163免费邮箱官网主站入口-163免费邮箱海外版登录通道 12-16
- 闪耀暖暖水中拍照有哪些技巧 12-16