Introduction
This article describes how to find the names of countries and cities using the IP address.
Using the code
The code is given below with explanations:
string IP = Request.ServerVariables["REMOTE_ADDR"];
XmlDocument doc = new XmlDocument();
doc.Load("http://www.showmyip.com/xml/?ip=" + IP);
XmlNodeList nodeLstCountry = doc.GetElementsByTagName("lookup_country");
XmlNodeList nodeLstCity = doc.GetElementsByTagName("lookup_city2");
IP = "Country :" + nodeLstCountry[0].InnerText +
" -- City :" + nodeLstCity[0].InnerText + "" + IP;
Response.Write(IP);
Page.Header.Title = "I am muslim before anything";
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here