在windows2008r2下,本机调试时asp.net获取的Ip地址为::1,请问这是为什么?
获取的代码是:
HttpRequest request = HttpContext.Current.Request;
string result = request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (string.IsNullOrEmpty(result))
{
result = request.ServerVariables["REMOTE_ADDR"];
}
if (string.IsNullOrEmpty(result))
{
result = request.UserHostAddress;
}
return result;