获取客户端IP
时间:2014-01-15 08:45:04
收藏:0
阅读:405
if(Context.Request.ServerVariables["HTTP_VIA"]!=null) // using proxy
{
ip=Context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString(); // Return real client IP.
}
else// not using proxy or can‘t get the Client IP
{
ip=Context.Request.ServerVariables["REMOTE_ADDR"].ToString(); //While it can‘t get the Client IP, it will return proxy IP.
}
原文:http://www.cnblogs.com/alanDJ/p/3514011.html
评论(0)