How to retrieve the client's machine name from within a WCF Operation Contract?

10k views Asked by At

I'm currently looking at the OperationContect.Current properties. Is there a (nested) property the will always return the machine name of the client? I'm currently using net.tcp binding, but would like to support additional bindings in the future.

Using .NET 3.5 SP1

1

There are 1 answers

3
Chris Wenham On BEST ANSWER

You can get the remote endpoint's IP address from the current OperationContext's IncomingMessageProperties, eg:

RemoteEndpointMessageProperty messageProperty = OperationContext.Current.IncomingMessageProperties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
Console.WriteLine("Remote address is: {0}", messageProperty.Address);