Obtaining the server IP address in WCF?

Posted by chris on Stack Overflow See other posts from Stack Overflow or by chris
Published on 2010-03-09T13:59:36Z Indexed on 2010/03/15 8:49 UTC
Read the original article Hit count: 261

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about .NET

Related posts about wcf