2011-12-28 65 views
3

从ASP.NET页,我能够检索客户端的IP地址(至少是明显的一个)。GEOIP找到国家从ASP.NET

我想知道如果有一个免费的服务,我可以从代码隐藏访问,将返回国(无需市)在与IP查询。

我不能凑合着用基于网络的HTTP服务,你必须手动输入IP,我有成千上万每天的访问!

任何线索欢迎。

回答

3

是,Check It Out

祝你好运!

编辑:既然你没有指定我继续创建了自己的用于测试目的键,使这个小样本的语言。这会得到任何给定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 
+2

为simpkicity和使用(韩国 “KR” 共和国) VB!谢谢。 – 2011-12-28 22:18:56

4

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

http://api.wipmania.com/123.45.67.89 

返回两个字母的国家代码

KR