清青春明 2014-07-31 14:45 采纳率: 0%
浏览 4313

WCF获取客户端IP 获取的不正确

我在网上按照这段代码,不知道为什么获取的不正确

        OperationContext context = OperationContext.Current;
        //获取传进的消息属性
        MessageProperties properties = context.IncomingMessageProperties;
        //获取消息发送的远程终结点IP和端口
        RemoteEndpointMessageProperty endpoint = properties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
        Console.WriteLine(string.Format("Hello {0},You are  from {1}:{2}", name, endpoint.Address, endpoint.Port));
        return string.Format("Hello {0},You are  from {1}:{2}", name, endpoint.Address, endpoint.Port);

老是获取的IP是:::1 ,我不明白为啥? 谁能告诉我?

  • 写回答

2条回答 默认 最新

  • caoqiangwd 2015-10-29 12:40
    关注

    LZ 我也遇到了 请问这是怎么回事呀

    评论

报告相同问题?

悬赏问题

  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型