zoukankan      html  css  js  c++  java
  • WebService及WCF获取客户端IP,端口

     1 //WebService
     2 
     3 string clientIP = HttpContext.Current.Request.UserHostAddress;
     4 
     5 
     6 //WCF
     7 
     8            //提供方法执行的上下文环境
     9             OperationContext context = OperationContext.Current;
    10             string toa = context.IncomingMessageHeaders.Action;
    11             Uri to = context.IncomingMessageHeaders.To;
    12             //获取传进的消息属性
    13             MessageProperties properties = context.IncomingMessageProperties;
    14             //获取消息发送的远程终结点IP和端口
    15             RemoteEndpointMessageProperty endpoint = properties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
    16 
    17        string msg = String.Format("IP[{0}]Port[{1}]Url[{2}]Action[{3}]访问受限", endpoint.Address, endpoint.Port, to.AbsoluteUri, toa);
    18                 Logger.WriteInfo(msg, "", logPath, GlobalContext.Logs);
  • 相关阅读:
    带勾选框的组织F4
    VBA 学习
    MACD指标量化策略实战案例
    DOM
    JS基础下
    JS基础
    CSS基础
    html实战4--transform3D
    html实战3--精灵图
    html实战2--四叶草
  • 原文地址:https://www.cnblogs.com/yf2011/p/5167419.html
Copyright © 2011-2022 走看看