Code :
string strURL = "http://ipinfodb.com/ip_query.php?ip=115.75.118.19";Function :
private string ProcessResponse(string SiteUrl)
{
string result = "";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri(SiteUrl));
try
{
WebResponse response = request.GetResponse();
Stream dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string responseFromServer = reader.ReadToEnd();
//
XmlTextReader xmlTextReader = new XmlTextReader(new StringReader(responseFromServer));
while (xmlTextReader.Read())
{
if (xmlTextReader.LocalName=="Ip")
txtIP.Text= xmlTextReader.ReadString();
if (xmlTextReader.LocalName == "Status")
txtStatus.Text = xmlTextReader.ReadString();
if (xmlTextReader.LocalName == "CountryCode")
txtCountryCode.Text= xmlTextReader.ReadString();
if (xmlTextReader.LocalName == "RegionCode")
txtRegionCode.Text= xmlTextReader.ReadString();
if (xmlTextReader.LocalName == "RegionName")
txtRegionName.Text= xmlTextReader.ReadString();
if (xmlTextReader.LocalName == "ZipPostalCode")
txtZipPostalCode.Text= xmlTextReader.ReadString();
if (xmlTextReader.LocalName == "Latitude")
txtLatitude.Text= xmlTextReader.ReadString();
if (xmlTextReader.LocalName == "Longitude")
txtLongitude.Text= xmlTextReader.ReadString();
if (xmlTextReader.LocalName == "Timezone")
txtTimezone.Text= xmlTextReader.ReadString();
if (xmlTextReader.LocalName == "Gmtoffset")
txtGmtoffset.Text= xmlTextReader.ReadString();
if (xmlTextReader.LocalName == "Dstoffset")
txtDstoffset.Text= xmlTextReader.ReadString();
}
return result;
}
catch
{
return "";
}
}
Source Code : Click Here To Download
Comments
No responses to “Get Information About IP address”
Post a Comment