IP 地址 127.0.0.1 的地理位置错误
好的,所以我尝试实现这个,http://ipaddressextensions.codeplex.com/。
它显示的输出为:-
127.0.0.1 RESERVED ZZ
这个“RESERVED”和“ZZ”到底是什么?它应显示为“INDIA IN”。
IP地址是本地主机的IP地址。好吧,但是国家名称和国家代码呢?为什么它们不能正确显示?我的代码需要更改什么?
OK, so I tried implementing this, http://ipaddressextensions.codeplex.com/.
It is displaying the output as:-
127.0.0.1 RESERVED ZZ
What on earth is this "RESERVED" and "ZZ"? It should be displayed as "INDIA IN".
The IP address is of the local host. All right, but what about the country name and country code? Why won't they display correctly? What do I need to change in my code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
127.0.0.1 是一个保留的 IP 地址,代表 localhost(运行代码的计算机)。这是每台运行 TCP/IP 的计算机的“有效”IP 地址。
IP 查找需要真实 IP 地址才能正常工作。
关于国家/地区代码 - 它可能是 2 个字符的国家/地区 ISO 代码(请参阅 这里),因此您需要将代码翻译为正确的国家/地区。
ZZ
不在表中,表示没有国家。127.0.0.1 is a reserved IP address which stands for localhost (the computer that the code is running on). This is a "valid" IP address for every computer that runs TCP/IP.
IP lookups need a real IP address in order to work correctly.
In regards to the country code - it is probably a 2 character country ISO code (see here), so you need to translate the code to the correct country.
ZZ
is not in the table, signifying no country.127.0.0.1
被称为环回地址,是您的系统用来有效地与自身对话的地址。因此,没有与该 IP 地址关联的国家/地区……它在每个系统上无处不在。如果您将代码发布到网络上,您会得到更合适的结果,因为每个访问系统都将使用公共 IP 地址来访问您的服务器。
127.0.0.1
is known as the loopback address and is what your system uses to talk to itself effectively. As a result, there is no country associated with that IP address... it's everywhere on every system.If you put your code out onto the web you'd get more appropriate results as each visiting system would be using a public IP address to reach your server.
当您在家进行测试时,服务器和用户都是一体的(您的 PC)。因此,您不能指望它显示国家/地区,因为 IIS 的 IP 地址是自身地址。
你的代码似乎没问题。您还可以使用免费的 ASP.NET 支持主机在线试用您的网站。有很多类似 HelioHost、0000free 等。
关于问题的编辑部分,如果您针对每个国家/地区使用不同版本的网站,那么最好使用开关。
我认为它看起来确实更整洁。
When you are testing from home, both server and user are one (your PC). So you can't expect it to show the country as the IP address for IIS is a self address.
Your code seems to be fine. Also you can use a free ASP.NET supporting host to try your website online. There are many like HelioHost, 0000free, etc.
Regarding the edit part of your question, if you are using different versions of the site for each country then wouldn't be using a switch better.
I think it does look neater.