如何获取一个WCF远程端点的IP地址? [英] How to get the IP address of a WCF remote endpoint?

查看:174
本文介绍了如何获取一个WCF远程端点的IP地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法让一个WCF连接的远程IP地址?

Is there a way to get the remote IP Address of a WCF connection?

我想,为什么它没有内置到WCF框架的原因是WCF可以与非TCP / IP绑定工作,因此IP地址并不总是有意义的。

I guess the reason why it's not built-in into the WCF framework is that WCF can work with non TCP/IP bindings, so the IP Address is not always meaningful.

然而,信息才有意义为所有广泛使用的绑定(据我所知:BasicHttp,DualHttp,WSHttp和NetTcp)。

However, the information would make sense for all the widely used bindings (As far as I know : BasicHttp, DualHttp, WSHttp and NetTcp).

的IP地址可能是访问使用反射,但我宁愿找一个记录的方式来获得它,而不是黑客进入的框架类。

The IP address is probably accessible using reflexion, but I'd rather find a documented way to get it rather than hacking into the framework classes.

我GOOGLE了在这个问题上,似乎很多人都碰到它没有找到一个体面的解决办法(通常的答案是<一个href="http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/d6de4e3b-cbe1-4e7f-993f-573f57b0905f/">to依靠邮件头的,但是这意味着信任的客户提供其真实IP地址,这是不是一种选择,如果你想登录出于安全原因,IP地址)

I've googled on the issue, and it seems a lot of people have run into it without finding a decent solution (The usual answer is to rely on the message headers, but this implies trusting the client to provide its real IP Address, which is not an option if you want to log the IP Address for security reasons)

推荐答案

显然,它已经在3.5通过<一加href="http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.remoteendpointmessageproperty.aspx">RemoteEndpointMessageProperty;看到这里

Apparently it has been added in 3.5 via RemoteEndpointMessageProperty; see here.

这篇关于如何获取一个WCF远程端点的IP地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆