Q:

Check browser geo location capability and get Latitude and Longtitude

I am developing .net MVC application. 
I want to get Geo Location from if it is support html 5.0 browser.
But I want to know can I do it inside a Controller (HomeController, inside index method)
Need your suggestions
Thank You 
   Yohan

A:

If you add a reference to jQuery in your project, you should then be able to add the following Javascript code to your view. This will then post to your controller with the long and lat. That is the only way you will be able to get the GeoLocation in your controller.
NOTE: This code hasn't been tested! I just wrote it quickly from memory.
// Get the coordinates
navigator.geolocation.getCurrentPosition(show_map);

function show_map(position) {
  var latitude = position.coords.latitude;
  var longitude = position.coords.longitude;

  // post to your controller
  var url = "/Home/Index?latitude=" + latitude + "&longtitude=" + longitude; 
  $.post(url, function(data) {
  });
}

You will also need to add the parameters "latitude" and "longtitude" to your controller.
  public ActionResult Index(string latitude, string longtitude)
  {

  }

