I have a WCF service that is called from various places
I have a method to get the ip and hostname of the caller.
But I was hoping to be able to get the full url of the caller if it's another service, aspx page, etc that is making the call.
Is that possible?
Currently what I have is essentially this:
public static string GetHostName()
{
var hostName = "UNKOWN";
try
{
var remoteEndpointMessageProperty = OperationContext.Current.IncomingMessageProperties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
hostName = remoteEndpointMessageProperty.Address;
var hostEntry = Dns.GetHostEntry(hostName);
hostName = hostEntry.HostName;
}
catch
{
}
return hostName;
}
Yes, I know the code is not currently clean (empty catch, etc), it's a proof of concept at the moment...