Articles → .NET → Get Location Information In Windows 7 Without Location Sensor In C#

Get Location Information In Windows 7 Without Location Sensor In C#








Service For Getting Location





Code To Get Location




using Newtonsoft.Json;
using System;
using System.Net.Http;

namespace ReadJson {
  class Program {
    static void Main(string[] args) {
      using(HttpClient client = new HttpClient()) {
        client.BaseAddress = new Uri("http://ip-api.com");
        HttpResponseMessage response = client.GetAsync("/json").Result; // Blocking call!  
        if (response.IsSuccessStatusCode) {
          dynamic stuff = JsonConvert.DeserializeObject(response.Content.ReadAsStringAsync().Result);

          Console.WriteLine(stuff.lat);
          Console.WriteLine(stuff.lon);
          Console.ReadLine();
        }
      }

    }
  }
}





Posted By  -  Karan Gupta
 
Posted On  -  Wednesday, March 15, 2017

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250