日期:2014-05-17  浏览次数:20406 次

asp.net怎么获取服务器端得到访问者的外网IP
asp.net怎么获取服务器端得到访问者的外网IP,要真实的外网IP,不要局域网的
asp.net

------解决方案--------------------

public string IpAddress()
{
string strIpAddress;
strIpAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (strIpAddress == null)
{
strIpAddress = Request.ServerVariables["REMOTE_ADDR"];
}
return strIpAddress;
}