借助http://city.ip138.com/ip2city.asp返回ip。
string tempip = "";
try{
WebRequest wr = WebRequest.Create("http://city.ip138.com/ip2city.asp");
Stream s = wr.GetResponse().GetResponseStream();
StreamReader sr = new StreamReader(s, Encoding.Default);
string all = sr.ReadToEnd();
int start = all.IndexOf("[") + 1;
int end = all.IndexOf("]", start);
tempip = all.Substring(start, end - start);
sr.Close();
s.Close();
}catch(Exception e)
{
}
return tempip;