How to get current city name?

Posted by Gow.Net under ASP.NET on 6/25/2013 | Points: 10 | Views : 2567 | Status : [Member] | Replies : 2
Hi all

When user open my site i need to get current city name and disply how?

gowthaman8870226416


Responses

Posted by: Learningtorise on: 6/25/2013 [Member] Starter | Points: 25

Up
0
Down
//this line is to check the clien ip address from the server itself
string IP = Request.ServerVariables["REMOTE_ADDR"];

//Initializing a new xml document object to begin reading the xml file returned
XmlDocument doc = new XmlDocument();

//NOTE: www.showmyip.com only allows 199 request/day
//as a free call, for more requests u could register with them
/////////////////

//send the request to www.showmyip.com sending the ip as a query string
//and loads the xml file in the document object
doc.Load("http://www.showmyip.com/xml/?ip=" + IP);

//begin finding the country by tag name
XmlNodeList nodeLstCountry = doc.GetElementsByTagName("lookup_country");

////begin finding the city by tag name
XmlNodeList nodeLstCity = doc.GetElementsByTagName("lookup_city2");

//concatinating the result for show, u could also use it
//to save in data base
IP = "Country :" + nodeLstCountry[0].InnerText +
" -- City :" + nodeLstCity[0].InnerText + "" + IP;
Response.Write(IP);

//this is my header that I love
Page.Header.Title = "I am Indian before anything";

http://hashtagakash.wordpress.com/

Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: aswinialuri-19361 on: 6/25/2013 [Member] Starter | Points: 25

Up
0
Down
Hi gowtham ,
refer this i think it will be useful to you

http://www.aspdotnet-suresh.com/2013/01/javascript-get-user-details-ip-address.html

Mark as Answer if it helps you
Thanks&Regards
Aswini Aluri

Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response