日期:2014-05-17 浏览次数:20486 次
/// <summary>
/// 获取IP
/// </summary>
/// <returns></returns>
public static string GetIpString()
{
string user_IP = "";
System.Web.HttpContext context = System.Web.HttpContext.Current;
if (context.Request.ServerVariables["HTTP_VIA"] != null) //判断是否有代理
{
user_IP = context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
}
else
{
user_IP = context.Request.ServerVariables["REMOTE_ADDR"].ToString();
}
return user_IP;
}