http://stackoverflow.com/questions/3937773/wcf-security-using-client-ip-address

(exposed on WebHttpBinding). 

OperationContext context = OperationContext.Current;
MessageProperties messageProperties = context.IncomingMessageProperties;
RemoteEndpointMessageProperty endpointProperty = messageProperties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
HttpRequestMessageProperty requestProperty = messageProperties[HttpRequestMessageProperty.Name] as HttpRequestMessageProperty;
myip = !string.IsNullOrEmpty(requestProperty.Headers["X-Real-IP"]) ? requestProperty.Headers["X-Real-IP"] : endpointProperty.Address;

wcf 获取客户端 IP的更多相关文章

  1. WebService及WCF获取客户端IP,端口

    wcf获取客户端IP,端口 var context = OperationContext.Current; var properties = context.IncomingMessageProper ...

  2. WCF获取客户端IP和端口

    //提供方法执行的上下文环境 OperationContext context = OperationContext.Current; //获取传进的消息属性 MessageProperties pr ...

  3. WCF 获取客户端IP

    public class Service2 : IService2 { public User DoWork() { Console.WriteLine(ClientIpAndPort()); }; ...

  4. PHP获取客户端IP

    /** * 获取客户端IP */ function getClientIp() { $ip = 'unknown'; $unknown = 'unknown'; if (isset($_SERVER[ ...

  5. C#服务器获取客户端IP地址以及归属地探秘

    背景:博主本是一位Windows桌面应用程序开发工程师,对网络通信一知半解.一日老婆逛完某宝,问:"为什么他们知道我的地址呢,他们是怎么获取我的地址的呢?" 顺着这个问题我们的探秘 ...

  6. 在Thinkphp3.2.3框架下实现自动获取客户端IP地址的get_client_ip()函数

    在Thinkphp框架下使用get_client_ip()函数获取客户端IP地址十分方便: 一行代码便可以实现:$ip = get_client_ip(); 但当我们测试时会遇到后台获取的IP地址显示 ...

  7. JAVA获取客户端IP地址

    在JSP里,获取客户端的IP地址的方法是:request.getRemoteAddr(),这种方法在大部分情况下都是有效的.但是在通过了Apache,Squid等反向代理软件就不能获取到客户端的真实I ...

  8. nodejs获取客户端IP Address

    在网上看见很多问node.js如何获取客户端IP,所以记录下来,以供大家参考. function getClientIp(req) { return req.headers['x-forwarded- ...

  9. nginx lua获取客户端ip

    --获取客户端ip function get_client_ip() local headers=ngx.req.get_headers() local ip=headers["X-REAL ...

随机推荐

  1. 【Avalon】escape

    [\uD800-\uDBFF][\uDC00-\uDFFF] var rsurrogate = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g var rnoalphanumeri ...

  2. web相关问题总结 - imsoft.cnblogs

    1,问题:编辑好的web程序乱码,显示不正常 解决方法:在head中加入一下代码,设置网页使用的语言为中文. <meta http-equiv="Content-Type" ...

  3. SpringMVC List绑定

    需求:成绩录入(录入多门课成绩,批量提交) 使用List接收页面提交的批量数据,通过包装pojo接收,在包装pojo中定义list<pojo>属性 public class ItemsQu ...

  4. codeforces 192 D

    link: http://codeforces.com/contest/330/problem/D The discription looks so long, but the problem is ...

  5. URAL(timus)1709 Penguin-Avia(并查集)

    Penguin-Avia Time limit: 1.0 secondMemory limit: 64 MB The Penguin-Avia airline, along with other An ...

  6. LeetCode()Substring with Concatenation of All Words 为什么我的超时呢?找不到原因了!!!

    超时代码 class Solution { public: vector<int> findSubstring(string s, vector<string>& wo ...

  7. Java——java多态

     /* * 多态: * 成员的特点: * 1.成员变量. *  编译时:参开引用型变量所属类中的是否有调用的成员变量,  有:编译通过,  没有  编译失败. *  运行时: 参考引用变量所属的类 ...

  8. springMvc源码学习之:spirngMVC获取请求参数的方法2

    @RequestParam,你一定见过:@PathVariable,你肯定也知道:@QueryParam,你怎么会不晓得?!还有你熟悉的他 (@CookieValue)!她(@ModelAndView ...

  9. java的nio之:java的nio系列教程之pipe

    Java NIO 管道是2个线程之间的单向数据连接.Pipe有一个source通道和一个sink通道.数据会被写到sink通道,从source通道读取. 这里是Pipe原理的图示:

  10. java多线程:jdk并发包的总结(转载)

    转载地址:http://blog.csdn.net/yangbutao/article/details/8479520 1.java 高并发包所采用的几个机制(CAS,volatile,抽象队列同步) ...