WCF常用取值方法

取客户端的IP地址:

var remote = System.ServiceModel.OperationContext.Current.IncomingMessageProperties[System.ServiceModel.Channels.RemoteEndpointMessageProperty.Name] as System.ServiceModel.Channels.RemoteEndpointMessageProperty;
var ip = remote.Address;

 

取请求流长度:

System.ServiceModel.Web.WebOperationContext.Current.IncomingRequest.ContentLength

你可能感兴趣的:(WCF)