tags:

views:

67

answers:

1

Is there a way to get the host name of the cleint making the call to a net.tcp binding in WCF. I'm trying to Diagnose an issue and I'd like to find out which client is sending me the message which is causing it.

I've tried:

OperationContext.Current.Channel.RemoteAddress.Uri.AbsoluteUri

But that only seems to give me a generic schema rather than a host name/ip address.

+1  A: 

I think RemoteAddress is only valid for duplex channels. What you need is the RemoteEndpointMessageProperty, like:

var remp = OperationContext.Current.IncomingMessageProperties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
string addr = remp.Address;
// do a DNS lookup or whatever from here if you want the hostname
nitzmahone