views:

207

answers:

1

How can I obtain the server address that was used for a request when it has multiple IP addresses?

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.

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: still looking for a solution...

A: 

Without any additional help and work from your side, I don't think you can get this.

The client sends a message to a URL - the message gets serialized, sent, handled, and sent back. There's no "standing connection" that you could query, there's nothing the server will do to tell you.

What you could do, is create a Message Inspector extension, that could be registered in the server side, and that would write the local IP of the server into a header field which you could then inspect on the client side.

Google or Bing for "WCF Message Inspectors" and you should find quite a few hits - some of the better ones:

marc_s
Sorry, my question wasn't clear enough - I need the information on the server. Please see my edits.
chris