Answered by:
get country code from IP Address (.NET solution or API)

Question
-
Hi,
I'm experiencing some issues when trying to get the country code for a given IP address.
After researching for a while on the internet, I read that the API of hostip.info offers this information within XML format.
http://api.hostip.info/?ip=91.216.236.169
The problem is that for some IP addresses I get "unknown" result. Above you can see one example.
My question is if exists another API or software for .NET platform (free or not free) that could supply me the country code for all the IP addresses of the world.
Thanks for your comments.
Have nice day.
Answers
-
Hi,
Refer the following Source codes for your Req.
http://dotnetguts.blogspot.in/2008/06/finding-country-from-visitors-ip-in.html
http://www.codeproject.com/Articles/28363/How-to-convert-IP-address-to-country-name
the below shows some 3rd party tool, which you can able to try the Demo and check.
http://www.dotnetcountry.com/demo.aspx
http://ip-to-country.webhosting.info/book/print/5
Don't forget to mark the post as answer or vote as helpful if it does, Regards - Rajasekhar.R
- Proposed as answer by Neddy Ren Monday, March 5, 2012 2:28 AM
- Marked as answer by Neddy Ren Tuesday, March 6, 2012 6:20 AM
- Unmarked as answer by blinkins0n Tuesday, March 6, 2012 10:00 AM
- Marked as answer by blinkins0n Tuesday, March 6, 2012 10:00 AM
-
go throuh this demo of using asp.net. Its simple and quiet easy.
IP to Location Finder API demo
Thank You.
hav fun with coding.
regds
Me
- Marked as answer by blinkins0n Tuesday, March 6, 2012 10:00 AM
All replies
-
You can try with IPInfoDB: http://ipinfodb.com/ip_location_api.php.
Marco Minerva [MCPD]
Blog: http://blogs.ugidotnet.org/marcom
Twitter: @marcominerva -
Hi,
Refer the following Source codes for your Req.
http://dotnetguts.blogspot.in/2008/06/finding-country-from-visitors-ip-in.html
http://www.codeproject.com/Articles/28363/How-to-convert-IP-address-to-country-name
the below shows some 3rd party tool, which you can able to try the Demo and check.
http://www.dotnetcountry.com/demo.aspx
http://ip-to-country.webhosting.info/book/print/5
Don't forget to mark the post as answer or vote as helpful if it does, Regards - Rajasekhar.R
- Proposed as answer by Neddy Ren Monday, March 5, 2012 2:28 AM
- Marked as answer by Neddy Ren Tuesday, March 6, 2012 6:20 AM
- Unmarked as answer by blinkins0n Tuesday, March 6, 2012 10:00 AM
- Marked as answer by blinkins0n Tuesday, March 6, 2012 10:00 AM
-
go throuh this demo of using asp.net. Its simple and quiet easy.
IP to Location Finder API demo
Thank You.
hav fun with coding.
regds
Me
- Marked as answer by blinkins0n Tuesday, March 6, 2012 10:00 AM
-
Hi,
I just implemented GeoLite Country free solution http://www.maxmind.com/app/geolitecountry
99.5% accurate
It uses a file.dat with Ip addresses
Any problems in using this solution?
Thanks!
-
Hi,
I just implemented GeoLite Country free solution http://www.maxmind.com/app/geolitecountry
99.5% accurateIt uses a file.dat with Ip addresses
Any problems in using this solution?
Thanks!
Neddy Ren[MSFT]
MSDN Community Support | Feedback to us
-
-
string Country name=GetIP("IP address"); private string GetIP(string ipadd) { string str = ""; try { if (!(ipadd != "")) return str; HttpWebRequest httpWebRequest = WebRequest.Create(new Uri("http://freegeoip.net/json/" + ipadd)) as HttpWebRequest; httpWebRequest.Method = "GET"; httpWebRequest.ContentType = "text/xml"; using (HttpWebResponse httpWebResponse = httpWebRequest.GetResponse() as HttpWebResponse) { str = new StreamReader(httpWebResponse.GetResponseStream()).ReadToEnd().Split(',')[2].Replace("\\", "").Split(':')[1].ToString(); str = str.Substring(1, str.Length - 1); return str = str.Substring(0, str.Length - 1); } } catch { return str; } }
- Edited by Jeetendra Negi Thursday, November 5, 2015 4:37 PM