- 获取客户端IP
private string GetClientIP()
{
string result = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (null == result || result == String.Empty)
{
result = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
}
if (null == result || result == String.Empty)
{
result = HttpContext.Current.Request.UserHostAddress;
}
return result;
}
- 获取Web服务器IP
private string GetServerIP()
{
return System.Web.HttpContext.Current.Request.ServerVariables["Local_Addr"];
}
时间: 2024-10-24 07:16:30