我有一个WCF服务,通过IIS在多个Web服务器上托管.我有一个记录方法,记录对数据库的调用,我想记录正在执行调用的服务器.
有谁知道如何获取WCF调用正在执行的主机服务器名称或IP地址?
这对我们有用.确保您具有对System.ServiceModel的引用.然后在您的服务方法中实现以下代码:
var context = System.ServiceModel.OperationContext.Current;
RemoteEndpointMessageProperty property = (RemoteEndpointMessageProperty)context.IncomingMessageProperties[RemoteEndpointMessageProperty.Name];
string externalIP = property.Address;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17570 次 |
| 最近记录: |