var ip=context.Request.UserHostAddress;

string url = "http://int.dpool.sina.com.cn/iplookup/iplookup.php?ip=" + ip;
WebClient MyWebClient = new WebClient();
MyWebClient.Credentials = CredentialCache.DefaultCredentials;//获取或设置用于向Internet资源的请求进行身份验证的网络凭据
Byte[] pageData = MyWebClient.DownloadData(url); //从指定网站下载数据
string stt = Encoding.GetEncoding("GBK").GetString(pageData).Trim();
return stt.Substring(stt.Length - 2, 2);

posted on 2018-05-10 13:21  天涯浪子1955  阅读(752)  评论(0编辑  收藏  举报