Didier Levy
Didier Levy

Reputation: 3453

geoIP find country from ASP.NET

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.

Upvotes: 3

Views: 3287

Answers (3)

Eduardo Molteni
Eduardo Molteni

Reputation: 39453

I use WIPmania, very, very easy:

http://api.wipmania.com/123.45.67.89

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

KR

Upvotes: 4

Hanlet Escaño
Hanlet Escaño

Reputation: 17380

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

Upvotes: 3

lamchakchan
lamchakchan

Reputation: 71

Found this that might be up your alley.

IP2Location

Upvotes: 0

Related Questions