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

 

posted on 2010-09-09 21:55  大豆男生  阅读(693)  评论(0编辑  收藏  举报

导航