Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get user location by IP address

Tags:

c#

asp.net

I have an ASP.NET website written in C#.

On this site I need to automatically show a start page based on the user's location.

Can I get name of user's city based on the IP address of the user ?

like image 373
Damir Avatar asked Dec 01 '10 18:12

Damir


People also ask

Can you find someone's location from their IP address?

Through a useful internet tool called IP Geolocation Lookup, you can track an IP address close to someone's exact location. You can get pretty close, depending on a variety of factors, to finding the physical location of someone's IP address.

How do I get the geolocation of an IP address?

Just send HTTP GET request to https://api.ipgeolocationapi.com with different parameters and get the JSON result. For example, the following HTTP GET request will give you a location of the specified IP address. The following request returns the country information specified by the ISO country code.


1 Answers

You need an IP-address-based reverse geocoding API... like the one from ipdata.co. I'm sure there are plenty of options available.

You may want to allow the user to override this, however. For example, they could be on a corporate VPN which makes the IP address look like it's in a different country.

like image 162
Jon Skeet Avatar answered Sep 24 '22 15:09

Jon Skeet