Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在WCF服务中记录IP地址_C#_Wcf_Ip Address_Nlog - Fatal编程技术网

C# 在WCF服务中记录IP地址

C# 在WCF服务中记录IP地址,c#,wcf,ip-address,nlog,C#,Wcf,Ip Address,Nlog,我正在WCF服务中使用NLog,并希望记录呼叫者IP地址 我尝试过使用aspnet layoutRenders(${aspnet请求:serverVariable=remote\u host},${aspnet请求:serverVariable=remote\u addr},但是没有用,因为正在引发内部NLog异常,并且没有生成日志文件 有没有一种方法可以在WCF服务中记录IP地址,而无需将其作为参数传递给被调用的方法 var msg = OperationContext.Current

我正在WCF服务中使用NLog,并希望记录呼叫者IP地址

我尝试过使用aspnet layoutRenders(
${aspnet请求:serverVariable=remote\u host}
${aspnet请求:serverVariable=remote\u addr}
,但是没有用,因为正在引发内部NLog异常,并且没有生成日志文件

有没有一种方法可以在WCF服务中记录IP地址,而无需将其作为参数传递给被调用的方法

var msg = OperationContext.Current
          .IncomingMessageProperties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;

var address = msg.Address;