【问题标题】:Get client IP address in a WCF Service hosted using HTTPS 443 bindings在使用 HTTPS 443 绑定托管的 WCF 服务中获取客户端 IP 地址
【发布时间】:2012-06-18 09:32:01
【问题描述】:

在我的一个应用程序中,需要使用 HTTPS 443 绑定托管的 WCF 服务中的客户端 IP 地址。

我尝试了关于此问题的堆栈溢出和其他网站的大部分帖子,但是当我在服务器中托管我的应用程序时,它只是获取服务器 IP 地址,但我需要请求的客户端地址,任何人对此有任何想法

提前谢谢..

【问题讨论】:

  • 不要忘记,只有在您不在反向代理或 NAT 网桥之后才能实现。

标签: c# wcf https ip-address


【解决方案1】:

在 .NET 3.5 中,您可以使用以下模式(使用 System.ServiceModel

OperationContext context = OperationContext.Current; 
MessageProperties prop = context.IncomingMessageProperties; 
RemoteEndpointMessageProperty endpoint = prop[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
string ip = endpoint.Address; 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-07-21
    • 2021-05-14
    • 2014-02-21
    • 2010-09-10
    • 2017-01-17
    • 1970-01-01
    • 2011-07-15
    • 1970-01-01
    相关资源
    最近更新 更多