1

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...

CaffGeek
  • 21,856
  • 17
  • 100
  • 184

1 Answers1

1

That's not possible. All you can hope of getting is the IP address of the caller and of course any information contained in the request message and eventual HTTP headers.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928