IP 地址为 127.0.0.1 的地理定位错误

Geolocation error with IP address 127.0.0.1(IP 地址为 127.0.0.1 的地理定位错误)
本文介绍了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 的地理定位错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)