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?
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.
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.
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).
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.
You can use something like OperationContext.Current.IncomingMessageHeaders.To.Host
OperationContext.Current.IncomingMessageHeaders.To.Host