获取真实IP
public static string GetRealIP()
{
string ip;
try
{
HttpRequest request 
= HttpContext.Current.Request;

if (request.ServerVariables["HTTP_VIA"!= null)
{
ip 
= request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString().Split(',')[0].Trim();
}

else
{
ip 
= request.UserHostAddress;
}

}

catch (Exception e)
{
throw e;
}


return ip;
}

获取代理IP
public static string GetViaIP()
{
string viaIp = null;

try
{
HttpRequest request 
= HttpContext.Current.Request;

if (request.ServerVariables["HTTP_VIA"!= null)
{
viaIp 
= request.UserHostAddress;
}


}

catch (Exception e)
{

throw e;
}


return viaIp;


http://www.yuayu.com/blogview.asp?logID=489
posted on 2007-02-14 09:31  mbskys  阅读(351)  评论(0)    收藏  举报