asp.net怎么获取客户端的IP地址,不是服务器的ip

2024-12-29 17:33:59
推荐回答(2个)
回答1:

if HttpContext.Current.Request.UserHostAddress 为空
else

HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

回答2:

Request.UserHostAddress;