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

6

本文介绍了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 的地理定位错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

C# 中的多播委托奇怪行为?
Multicast delegate weird behavior in C#?(C# 中的多播委托奇怪行为?)...
2023-11-11 C#/.NET开发问题
6

参数计数与调用不匹配?
Parameter count mismatch with Invoke?(参数计数与调用不匹配?)...
2023-11-11 C#/.NET开发问题
26

如何将代表存储在列表中
How to store delegates in a List(如何将代表存储在列表中)...
2023-11-11 C#/.NET开发问题
6

代表如何工作(在后台)?
How delegates work (in the background)?(代表如何工作(在后台)?)...
2023-11-11 C#/.NET开发问题
5

没有 EndInvoke 的 C# 异步调用?
C# Asynchronous call without EndInvoke?(没有 EndInvoke 的 C# 异步调用?)...
2023-11-11 C#/.NET开发问题
2

Delegate.CreateDelegate() 和泛型:错误绑定到目标方法
Delegate.CreateDelegate() and generics: Error binding to target method(Delegate.CreateDelegate() 和泛型:错误绑定到目标方法)...
2023-11-11 C#/.NET开发问题
14