geoIP 从 ASP.NET 查找国家/地区

发布于 2024-12-22 23:59:32 字数 178 浏览 6 评论 0原文

我可以从 ASP.NET 页面检索客户端的 IP 地址(至少是表面上的 IP 地址)。

我想知道是否有可以从代码隐藏访问的免费服务,当使用 IP 查询时,该服务将返回国家/地区(不需要城市)。

我无法使用基于 Web http 的服务,您必须手动输入 IP,我每天有数千次访问!

欢迎任何线索。

From an ASP.NET page I'm able to retrieve the client's IP address (at least the apparent one).

I would like to know if there is a free service that I can access from code-behind, that will return the country (no need for city) when queried with the IP.

I can't make do with web http based services where you have to enter the IP manually, I have thousands of visits per day!

Any clue welcome.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

三寸金莲 2024-12-29 23:59:32

我使用 WIPmania,非常非常简单:

http://api.wipmania.com/123.45.67.89

返回两个字母的国家代码(“KR”韩国)

KR

I use WIPmania, very, very easy:

http://api.wipmania.com/123.45.67.89

returns two-letter country code ("KR" Republic of Korea)

KR
残花月 2024-12-29 23:59:32

是的,检查一下

祝你好运!

编辑:由于您没有指定语言,我继续创建自己的密钥以进行测试,并制作了这个小样本。这将获取任何给定 IP 地址的国家/地区。祝你好运。

Try
        Dim webClient As WebClient = New WebClient

        'I am at work so i need a proxy authentication
        'webClient.Proxy.Credentials = New NetworkCredential("username", "password")

        Dim stream As Stream = webClient.OpenRead("http://api.ipinfodb.com/v3/ip-country/?key=<key here>&ip=" & Context.Request.ServerVariables("REMOTE_ADDR"))
        Dim sReader As New StreamReader(stream)
        Dim content As String = sReader.ReadToEnd()
        Response.Write(content.Split(";")(4))

    Catch ex As Exception
        Response.Write("Error occured")
    End Try

Yes, Check It Out!

Good luck!

EDITED: Since you did not specify a language I went ahead and created my own key for testing purposes and made this little sample. This gets the Country of any given IP address. Good luck.

Try
        Dim webClient As WebClient = New WebClient

        'I am at work so i need a proxy authentication
        'webClient.Proxy.Credentials = New NetworkCredential("username", "password")

        Dim stream As Stream = webClient.OpenRead("http://api.ipinfodb.com/v3/ip-country/?key=<key here>&ip=" & Context.Request.ServerVariables("REMOTE_ADDR"))
        Dim sReader As New StreamReader(stream)
        Dim content As String = sReader.ReadToEnd()
        Response.Write(content.Split(";")(4))

    Catch ex As Exception
        Response.Write("Error occured")
    End Try
帝王念 2024-12-29 23:59:32

发现这可能正合你的胃口。

IP2Location

Found this that might be up your alley.

IP2Location

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文