我有一个从各个地方调用的WCF服务
我有一个方法来获取调用者的ip和主机名。
但我希望能够获得调用者的完整URL,如果它是另一个服务,aspx页面等正在进行调用。
这可能吗?
目前我所拥有的基本上是这样的:
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;
}
是的,我知道代码目前还不干净(空捕获等),这是目前的概念验证......
答案 0 :(得分:1)
那是不可能的。您可以获得的只是调用者的IP地址,当然还包括请求消息和最终HTTP头中包含的任何信息。