Pages

Aug 26, 2010

How to find Country's Name using IP Address in Asp.Net

Use the below free web-service to get the country name using IP Address.
 http://www.webservicex.net/geoipservice.asmx?wsdl


Add the service to your web or windows application and name the service
as say for eg. locationFinder
Now access it in your code as
// Create instance for the service

LocationFinder.GeoIPService service = new LocationFinder.GeoIPService();
// Gets the country name.
string country = service.GetGeoIP("216.241.xxx.xx").CountryName;


To get the ipAddress of the Client machine use
String ipAddress = Request.UserHostAddress.ToString();

1 comment:

Unknown said...

It is creating problem for anonymous users.Do you have any idea for this?