积极答复者
一个小问题,获取客户端IP?

问题
答案
-
我在Web service这一端,如果获取请求服务的客户端IP地址,我用的是WSE3.0,我一开始用RequestSoapContext.Current.Actor.Host,发现取的是服务端的IP,而不是客户端的IP,请问能否取到?
Hi,
获取客户端IP方式很多吧,你可以都尝试一下:
1.使用HttpContext.Current.Request.UserHostAddress IP地址
2.CustomerIP=HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString();
3. CustomerIP=HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
4.NET中Web Service和Web Form获得客户端IP的方法:http://blog.csdn.net/lhsxsh/archive/2008/11/01/3199911.aspx
2.3使用的时候加非空判断:if(HttpContext.Current.Request.ServerVariables["HTTP_VIA"]!=null)
记得以前参与过Web Service安全的讨论:
1.http://space.cnblogs.com/question/7202/
2.http://space.cnblogs.com/question/6951/
Frank.Xu Lei--谦卑若愚,好学若饥
专注于.NET平台下分布式应用系统开发和企业应用系统集成
Focus on Distributed Applications Development and EAI based on .NET
老徐的博客:http://frank_xl.cnblogs.com- 已标记为答案 Andrew_ZhuModerator 2009年7月13日 2:22
全部回复
-
this.Context.Request.ServerVariables["REMOTE_ADDR"].ToString()
知识改变命运,奋斗成就人生!- 已建议为答案 邹俊才Moderator 2009年7月7日 2:15
-
我在Web service这一端,如果获取请求服务的客户端IP地址,我用的是WSE3.0,我一开始用RequestSoapContext.Current.Actor.Host,发现取的是服务端的IP,而不是客户端的IP,请问能否取到?
Hi,
获取客户端IP方式很多吧,你可以都尝试一下:
1.使用HttpContext.Current.Request.UserHostAddress IP地址
2.CustomerIP=HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString();
3. CustomerIP=HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
4.NET中Web Service和Web Form获得客户端IP的方法:http://blog.csdn.net/lhsxsh/archive/2008/11/01/3199911.aspx
2.3使用的时候加非空判断:if(HttpContext.Current.Request.ServerVariables["HTTP_VIA"]!=null)
记得以前参与过Web Service安全的讨论:
1.http://space.cnblogs.com/question/7202/
2.http://space.cnblogs.com/question/6951/
Frank.Xu Lei--谦卑若愚,好学若饥
专注于.NET平台下分布式应用系统开发和企业应用系统集成
Focus on Distributed Applications Development and EAI based on .NET
老徐的博客:http://frank_xl.cnblogs.com- 已标记为答案 Andrew_ZhuModerator 2009年7月13日 2:22