WCF 返回 IPv6 地址的不同部分

发布于 2024-12-26 06:11:59 字数 932 浏览 1 评论 0原文

我正在使用下面的代码来获取 WCF 中客户端的 IP 地址

  OperationContext context = OperationContext.Current;
  MessageProperties messageProperties = context.IncomingMessageProperties;
  RemoteEndpointMessageProperty endpointProperty =
            messageProperties[RemoteEndpointMessageProperty.Name]
            as RemoteEndpointMessageProperty;
  return endpointProperty.Address;

如果我在客户端上运行 ipconfig,我会得到:

Windows IP Configuration


Ethernet adapter Local Area Connection 3:

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::3864:610a:3dc:5acd%18
   IPv4 Address. . . . . . . . . . . : 192.168.1.249
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.1.250

我的问题是,在某些调用中,我收到来自我的客户端的 IP 地址。代码 fe80::3864:610a,因此我收到的其他调用 fe80::3864:610a:3dc:

这是正确的行为吗?我可以或者应该过滤这个吗?

I'm using the code below to get the IP address for the client in my WCF

  OperationContext context = OperationContext.Current;
  MessageProperties messageProperties = context.IncomingMessageProperties;
  RemoteEndpointMessageProperty endpointProperty =
            messageProperties[RemoteEndpointMessageProperty.Name]
            as RemoteEndpointMessageProperty;
  return endpointProperty.Address;

If I run a ipconfig on my client, I get:

Windows IP Configuration


Ethernet adapter Local Area Connection 3:

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::3864:610a:3dc:5acd%18
   IPv4 Address. . . . . . . . . . . : 192.168.1.249
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.1.250

My problem is that, on some calls, I receive from my code fe80::3864:610a, and so other calls I get fe80::3864:610a:3dc:

Is this a correct behavior? Can, or should, I filter this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文