获取WCF客户端IP

代码
/// <summary>
/// 获取WCF客户端IP
/// </summary>
public static string GetClientIp()
{
    MessageProperties messageProperties 
= OperationContext.Current.IncomingMessageProperties;
    RemoteEndpointMessageProperty endpointProperty 
= 
        messageProperties[RemoteEndpointMessageProperty.Name] 
as RemoteEndpointMessageProperty;
    
if (endpointProperty == null)
        
return string.Empty;
    
else
        
return endpointProperty.Address;
}
原文地址:https://www.cnblogs.com/anjou/p/1822643.html