WCF 获取客户端IP

  public class Service2 : IService2
    {
        public User  DoWork()
        {
            Console.WriteLine(ClientIpAndPort());
            return new User { Name = "sdf", Age = 12 };
        }
        public string ClientIpAndPort()
        {
            OperationContext context = OperationContext.Current;
            MessageProperties properties = context.IncomingMessageProperties;
            RemoteEndpointMessageProperty endpoint = properties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;

            return endpoint.Address+"port"+endpoint.Port;
        }
    }

 

上一篇:机器学习 科学数据库 Day3


下一篇:好用的Java数学表达式计算工具——Exp4j