title: Passing values to Controller via Javascript return View MVC3 Razor
body: <p>I am brand new to MVC.  I am trying to pass longitude and latitude values I obtain using geolocation to my controller so that I can use the values to identify and pull the correct data from my database.  </p>
  
  <p>Here is my Javascript</p>
  
  <pre><code>function auto_locate() {
  
  
      alert("called from station");
      navigator.geolocation.getCurrentPosition(show_map);
  
  
  
  function show_map(position) {
      var latitude = position.coords.latitude;
      var longitude = position.coords.longitude;
      var locstring = latitude.toString() + "." + longitude.toString();
      var postData = { latitude: latitude, longtitude: longitude }
      alert(locstring.toString());
  
  }
  
  }
  </code></pre>
  
  <p>All of this works fine; </p>
  
  <p>Now what I need to do is pass postData or locstring to my controller.  Which looks like this: </p>
  
  <pre><code>[HttpGet]
  public ActionResult AutoLocate(string longitude, string latitude)
  {
      new MyNameSpace.Areas.Mobile.Models.Geo
      {
          Latitude = Convert.ToDouble(latitude),
  
          Longitude = Convert.ToDouble(longitude)
  
      };
  
  
  // Do some work here to set up my view info then...
      return View();
  }
  </code></pre>
  
  <p>I have searched and researched and I have not been able to find a solution.  </p>
  
  <p>How can I call the javascript above from an HTML.ActionLink  and get the Longitide and Latitude to my controller?   </p>