读书人

Request.ServerVariables[quot;Remote_Add

发布时间: 2012-03-31 13:13:26 作者: rapoo

Request.ServerVariables["Remote_Addr"] 的问题
win7系统,IIS6.0
使用Request.ServerVariables["Remote_Addr"] 总得到 ::1
网络连接中 IP6的协议已勾掉,求解,如何获得本机 IP

[解决办法]
win7获取的是ipv6

string clientIP = string.Empty;

clientIP = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

if (string.IsNullOrEmpty(clientIP))
clientIP = Request.ServerVariables["HTTP_X_REAL_IP"];

if (string.IsNullOrEmpty(clientIP))
clientIP = Request.ServerVariables["REMOTE_ADDR"];

return clientIP;

读书人网 >ASP

热点推荐