private void GetLocationIPINFOTemp(string ipaddress) { ipInfo = new IPDataIPAPI(); //var url = "http://freegeoip.net/json/" + ClientIPaddress(); //var request = System.Net.WebRequest.Create(url); //string strdata=""; try { string strResponse = new WebClient().DownloadString("http://ipinfo.io/" + ipaddress); //if (strResponse == null || strResponse == "") return ""; ipInfo = JsonConvert.DeserializeObject <IPDataIPAPI>(strResponse); //if (ipInfo == null || ipInfo.ip == null || ipInfo.ip == "") return ""; //else return ipInfo.city + "; " + ipInfo.region + "; " + ipInfo.country + "; " + ipInfo.postal; //strdata = ipInfo.@as + " ** " + ipInfo.city + " ** " + ipInfo.country + " ** " + ipInfo.countryCode + " ** " + ipInfo.isp + " ** " + // ipInfo.lat + " ** " + ipInfo.lon + " ** " + ipInfo.org + " ** " + // ipInfo.query + " ** " + ipInfo.region + " ** " + ipInfo.regionName + " ** " + // ipInfo.status + " ** " + ipInfo.timezone + " ** " + // ipInfo.zip + " *Company ::* "+ ipInfo.company + " ** "; } catch (Exception) { // return ""; } //return strdata; }
IPDataIPAPI ipInfo;//= new IPDataIPAPI(); private void GetLocationIPINFO(string ipaddress) { ipInfo = new IPDataIPAPI(); try { string strResponse = new WebClient().DownloadString("http://ipinfo.io/" + ipaddress); ipInfo = JsonConvert.DeserializeObject <IPDataIPAPI>(strResponse); } catch (Exception) { } }