HttpContext.Current.Request.UserHostAddress为null.为什么?我怎么能打开它?使用ASP.net 4 window7的WCF服务.
谢谢
为了避免这个问题,你可以解析最后一个entery IP的HTTP_X_FORWARDED_FOR.
ip=Request.ServerVariables["HTTP_X_FORWARDED_FOR"] ;
if (!string.IsNullOrEmpty(ip))
{
string[] ipRange = ip.Split(',');
int le = ipRange.Length - 1;
string trueIP = ipRange[le];
}
else
{
ip=Request.ServerVariables["REMOTE_ADDR"];
}
Run Code Online (Sandbox Code Playgroud)
希望这会对你有所帮助
| 归档时间: |
|
| 查看次数: |
6286 次 |
| 最近记录: |