#Asp.Net获取用户真实IP方法
private static string GetClientIP(HttpContext context)
{
string result = context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (string.IsNullOrEmpty(result))
{
result = context.Request.ServerVariables["REMOTE_ADDR"];
}
return result;
}
如果不通过nginx访问,HTTP_X_FORWARDED_FOR为null