public static string GetIpaddress()
{
string result = String.Empty;
result = HttpContext.Current.Request.ServerVariables["HTTP_CDN_SRC_IP"];
if (string.IsNullOrEmpty(result))
result = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
if (string.IsNullOrEmpty(result))
result = HttpContext.Current.Request.UserHostAddress;
if (string.IsNullOrEmpty(result) || !IsIP(result))
return "127.0.0.1";
return result;
}
获取IP地址
原文:http://www.cnblogs.com/nzcblog/p/5073862.html