views:

2990

answers:

4

Hi,

I am having an application in which i am storing user ip address. But now i want to store the City, Country and Country Code of the user on the basis of their ip addresses. So I am able to get the user's IP Address in ASP.NET but how to get other details. If its possible (which i don't thin it is) then tell me else tell me some alternate way to do this, is there any online FREE service using which ican get these details.

How to do this in ASP.NET using C#

Thanks.

+1  A: 

You would need to use a service, such as one from Hostip.info (they have an API), to get the longitude-lattitude coordinates based on an IP address that you supply. Then you would need to geocode the coordinates, perhaps using the Google Maps API, so that you can get an actual mailing address.

Bullines
I don't know why but its providing me the wrong information, like i am in Delhi, India now whereas the hostip.info is showing it as Mumbai, India Isn't there any other FREE service, or is there any mechanism in ASP.NET ?
Prashant
This could occur if your ISP is in Mumbai or its DNS has your Internet traffic going through its Mumbai office. Unfortunately, IP addresses are usually not a reliable way to determine geographic location.
Bullines
Then what can be the reliable way to determine the City and Country of the user?
Prashant
Asking users to fill out a form, prompting them to enter their address.
Bullines
+4  A: 

Check this example code, using Hostip.info, as @Bullines said:

Geolocation/Geotargeting (Reverse IP Address Lookup) in ASP.NET MVC made easy

CMS
A: 

Use the Hostip.info API, also, there are some products you could buy... like IP2location

sebastian
A: 

Just check this answer it was quite useful

http://consult2code.com/index.php/7/need-of-world-country-state-city-database-can-any-one-help-me

Regards,
Paruthi

Paruthi