我有一个从不同地方调用的WCF服务
我有一个方法来获取调用者的IP和主机名。
但我希望能够得到完整的网址,如果是另一个服务,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;
}
是的,我知道代码目前不干净(空catch等),这是目前概念的证明…