简体   繁体   English

在ASMX Web服务上获取客户端的IP地址

[英]Getting the IP address of the client on an ASMX Web service

I am trying to Authenticate a web service by validating the IP address of the caller. 我正在尝试通过验证呼叫者的IP地址来验证Web服务。 The web service is meant to be internal to the network. Web服务是网络内部的。

and in trying to do so the HttpContext.Current.Request.UserHostAddress has a weird value like "::1" 并尝试这样做时,HttpContext.Current.Request.UserHostAddress具有一个奇怪的值,例如“ :: 1”

See debug point screenshot below. 请参见下面的调试点屏幕截图。

在此处输入图片说明

Questions : 问题:

  1. Why does this not work and give the proper ip of the client? 为什么这不起作用并给客户端正确的IP地址?
  2. Is there a better way to authenticate the Web Service for an internal client? 有没有更好的方法来为内部客户端认证Web Service?

Thanks in advance. 提前致谢。

  1. Why does this not work and give the proper ip of the client? 为什么这不起作用并给客户端正确的IP地址?

It is indeed working and you are seeing "::1" because it's a reserved loopback address for ipv6 AKA localhost or 127.0.0.1 in ipv4 它确实在工作,并且您看到“ :: 1”,因为它是ipv6 AKA本地主机或ipv4中的127.0.0.1的保留回送地址。

IPv6 IPv6的

The loopback address, 0000:0000:0000:0000:0000:0000:0000:0001, may be abbreviated to ::1 by using both rules. 通过使用这两个规则,可以将环回地址0000:0000:0000:0000:0000:0000:0000:0001缩写为:: 1。

  1. Is there a better way to authenticate the Web Service for an internal client? 有没有更好的方法来为内部客户端认证Web Service?

You have to know the difference between Authentication & Authorization, i suggest you create a new question with more details on the authentication methods that you are using in your web service 您必须了解身份验证和授权之间的区别,我建议您创建一个新问题,其中详细说明您在Web服务中使用的身份验证方法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM