Obtaining the server IP address in WCF?
- by chris
How can I obtain the server IP address that was used to connect to a service?
The server has multiple IP addresses and I need to know which one the client is connected to.
So far I only found that
OperationContext.Current.EndpointDispatcher.EndpointAddress and OperationContext.Current.Channel.LocalAddress contain the address from .config (e.g. localhost)
OperationContext.Current.IncomingMessageProperties.Via contains the Url that the client used to connect to the server (but this might just be a name from the clients hosts file).
EDIT - Sorry, I wasn't being clear enough:
The server needs to know which of its IP addresses were used by the client.
E.g.
the server has the addresses 10.0.0.1 and 10.0.0.2.
when processing the request the server service needs to know if 10.0.0.1 or 10.0.0.2 was used by the client to connect to it.