网站放到外网如何获取访问的客户端IP呢?请大家支支招吧,谢啦!
2 回答
至尊宝的传说
TA贡献1789条经验 获得超10个赞
public static string GetClientIP() { string clientIP = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; if (string.IsNullOrEmpty(clientIP)) clientIP = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]; if (string.IsNullOrEmpty(clientIP)) clientIP = HttpContext.Current.Request.UserHostAddress; if (string.IsNullOrEmpty(clientIP)) clientIP = "0.0.0.0"; return clientIP; }
- 2 回答
- 0 关注
- 614 浏览
添加回答
举报
0/150
提交
取消