c#获得客户端IP地址
时间:2011-01-04 来源:非凡·SmallWhite

#region GetIp 获得IP地址
public static string GetIp()
{
if (System.Web.HttpContext.Current.Request.ServerVariables["HTTP_VIA"] != null)
{
return System.Web.HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].
Split(new char[] { ',' })[0];
}
else
{
return System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
}
}
#endregion
相关阅读 更多 +
排行榜 更多 +