//------------------------------------------------------------------------- async Task _refreshIpAddress() { if (RemoteEndPoint != null) { try { WebClient client = new WebClient(); string uri = @"http://ip.taobao.com/service/getIpInfo.php?ip=" + RemoteEndPoint.Address.ToString();//+ "139.196.105.80"; string result_data = await client.DownloadStringTaskAsync(uri); IPCheckResult result = EbTool.jsonDeserialize <IPCheckResult>(result_data); if (result.code == 0) { EbLog.Note("Country=" + result.data.country + " Area=" + result.data.area); EbLog.Note("Region=" + result.data.region + " City=" + result.data.city + " County=" + result.data.county); string ip_address = result.data.country + "." + result.data.city; CoActor.Def.mPropIpAddress.set(ip_address); } } catch (Exception ex) { EbLog.Note(ex.ToString()); } } }
public static string getISPInfo(string IPAddress) { string strResult = ""; WebClient client = new WebClient(); string uri = @"http://ip.taobao.com/service/getIpInfo.php?ip=" + IPAddress; string jsonData = client.DownloadString(uri); IPCheckResult result = JsonConvert.DeserializeObject <IPCheckResult>(jsonData); if (result.code != 0) { return(""); } strResult = result.data.isp_id; return(strResult); }