代码
/// <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;
}
/// 获取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;
}