简体   繁体   English

如何从WCF服务应用程序获取客户端的地址?

[英]How do I get a client's address from a WCF Service Application?

How can I get a client's address from a WCF Service Application? 如何从WCF服务应用程序获取客户端的地址? Also, is there an event raised when a client connects, possibly with address information? 此外,当客户端连接时是否会引发事件,可能还有地址信息?

In 3.0, this is quite hard; 在3.0中,这很难; but was improved in 3.5 ( read Detect Client IP in WCF 3.5 ). 但在3.5中有所改进( 在WCF 3.5中读取检测客户端IP )。 I'm not aware of an event, though. 不过,我不知道有什么事。

Which address are you looking for? 你在找哪个地址? The IP address? IP地址?

If so, I hope you're aware of the limitations on that - it won't be accurate if the client's on the other side of a NAT device or Internet proxy. 如果是这样,我希望您了解其中的限制 - 如果客户端位于NAT设备或Internet代理的另一端,则不准确。

If System.Web.HttpContext.Current.Request.UserHostAddress isn't null, then it has the remote address. 如果System.Web.HttpContext.Current.Request.UserHostAddress不为null,则它具有远程地址。 But that might be a proxy or load balancer (the case I have in our production environment). 但这可能是代理或负载均衡器(我在生产环境中的情况)。

如果WCF主机提供获取服务请求者IP的方法会更容易 - 这样您就可以调用该方法来获取原始请求者。

您可以使用类似于OperationContext.Current.IncomingMessageHeaders.To.Host

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从WCF应用程序获取服务参考地址 - How to get Service Reference Address from WCF Application 如何从负载均衡器后面获取客户端的 IP 地址? - How do I get a client's IP address from behind a load balancer? C#从WCF服务获取客户端应用程序校验和 - C# Get the Client Application Checksum from the WCF Service 我如何使用WCF服务而不是套接字客户端服务器应用程序? - how do i use WCF service instead of socket client-server application? 为什么我的WCF客户端/服务会收到ActionNotSupportedException? - Why do I get ActionNotSupportedException for my WCF client/service? 如何获得WCF服务的侦听地址/端口? - How can I get the listening address/port of a WCF service? 如何使用Entity Framework将实体对象从WCF服务“传输”到客户端应用程序? - How can I “transport” an entity object from a WCF service to a client application with Entity Framework? 如何从客户端应用程序调用WCF REST / JSON服务 - How to call WCF REST/JSON Service from client application 我正在制作 wcf 服务应用程序如何获取 xml 文件的完整路径? - I am making a wcf service application how do I get the full path of a xml file? 如何从WCF服务获取客户端的URL? - How to obtain client's URL from WCF service?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM