IP 地址为 127.0.0.1 的地理定位错误 [英] Geolocation error with IP address 127.0.0.1

查看:29
本文介绍了IP 地址为 127.0.0.1 的地理定位错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,所以我尝试实现这个,http://ipaddressextensions.codeplex.com/.

OK, so I tried implementing this, http://ipaddressextensions.codeplex.com/.

将输出显示为:-

127.0.0.1 保留 ZZ

127.0.0.1 RESERVED ZZ

这个RESERVED"和ZZ"到底是什么?它应该显示为印度".

What on earth is this "RESERVED" and "ZZ"? It should be displayed as "INDIA IN".

IP 地址是本地主机的.好的,但是国家名称和国家代码呢?为什么它们不能正确显示?我需要对我的代码进行哪些更改?

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?

推荐答案

当您在家进行测试时,服务器和用户是一体的(您的 PC).所以你不能指望它显示国家,因为 IIS 的 IP 地址是一个自己的地址.

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.

您的代码似乎没问题.您也可以使用免费的 ASP.NET 支持主机在线试用您的网站.有很多像 HelioHost, 0000free

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.

switch(iso3166TwoLetterCode.ToUpper())
{
    case "IN" : Response.Redirect("www.mysite.in");
    case "FR" : Response.Redirect("www.mysite.fr");
    ...
    Default : Response.Redirect("www.mysite.in");
}

我认为它确实看起来更整洁.

I think it does look neater.

这篇关于IP 地址为 127.0.0.1 的地理定位错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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