How to get client address from WCF service application?

How can I get a client address from a WCF service application? Also, does an event occur when a client connects, possibly with address information?

+5
source share
5 answers

In 3.0, this is quite complicated; but it was improved in 3.5 ( read “Check client IP address in WCF 3.5 )). However, I do not know about the event.

+7
source

What address are you looking for? IP address?

If this is the case, I hope that you know about the limitations on this - it will not be accurate if the client is on the other side of a NAT device or Internet proxy.

+2
source

If System.Web.HttpContext.Current.Request.UserHostAddress is not null, then it has a remote address. But it can be a proxy server or a load balancer (a case that I have in our production environment).

+2
source

It would be easier if the WCF host provided a way to obtain the IP address of the service provider so that you could call this method to get the original request.

+1
source

You can use something like OperationContext.Current.IncomingMessageHeaders.To.Host

0
source

All Articles