如何在WCF服务中获取客户端IP地址 [英] How to get client IP address in WCF service
本文介绍了如何在WCF服务中获取客户端IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们可以在WCF服务中获取客户端IP地址吗?
Can we get client IP address in WCF service?
推荐答案
查看此解决方案:在使用HTTPS 443绑定托管的WCF服务中获取客户端IP地址 [ ^ ]
Check out this solution: Get client IP address in a WCF Service hosted using HTTPS 443 bindings[^]
OperationContext oOperationContext = OperationContext.Current;
MessageProperties oMessageProperties = oOperationContext.IncomingMessageProperties;
RemoteEndpointMessageProperty oRemoteEndpointMessageProperty = (RemoteEndpointMessageProperty)oMessageProperties[RemoteEndpointMessageProperty.Name];
string szAddress = oRemoteEndpointMessageProperty.Address;
int nPort = oRemoteEndpointMessageProperty.Port;
这篇关于如何在WCF服务中获取客户端IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文