在WCF的IPv4远程地址 [英] IPv4 remote address in WCF

查看:243
本文介绍了在WCF的IPv4远程地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

相关的http://计算器.COM /问题/ 391142 /如何对获得的非IP地址的一WCF的远程端点

我使用此代码检索时被调用工作流方法的远程IP地址:

I am using this code to retrieve the remote IP address when a workflow method is invoked:

private static string GetRemoteIP()
{
  var oc = OperationContext.Current;
  var mp = oc.IncomingMessageProperties;
  var remp = mp[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;

  return remp == null ? "(unknown)" : remp.Address;
}



不过,我回来的地址是:: 1。我不想IP​​v6地址,我要在IPv4一(127.0.0.1) - 这迫使任何方式

However, the address I get back is "::1". I don't want the IPv6 address, I want the IPv4 one (127.0.0.1) - any way of forcing this?

推荐答案

不,我不这么认为。你基本上只是读出的属性由客户端在调用的时候设置的。你唯一的选择是指导客户端(通过一些配置),以使用IPv4的IPv6的,而不是在任何时候(即关闭IPv6一起)。

No, I don't think so. You basically just read out a property set by the client at the time of the call. Your only option would be to instruct the client (through some config) to use IPv4 instead of IPv6 at all times (i.e. turn off IPv6 all together).

我不知道有任何WCF设置为强制 - 你必须深入到网络堆栈,看看是否有任何办法让它使用IPv4地址,而不是IPv6的

I'm not aware of any WCF setting to enforce that - you'd have to dig into the network stack and see if there's any way to make it use IPv4 addresses instead of IPv6.

这篇关于在WCF的IPv4远程地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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