I'm using C# and ASP.NET MVC5. The issue I'm coming across is relatively bizarre.

We have a multilingual website, using a _culture cookie for culture storage and changing the Thread.CurrentThread.CurrentCulture to reflect the user's culture. The website has a distributor locator on it.

Here's the issue:

When using the English language (en-CA in this case), our JSON from the distributor locator is submitted and parsed correctly. When using French (fr), the controller action shows 0.0 for the latitude and longitude, even if it shows a value when parsed in the Chrome devtools console. Radius is seemingly unaffected.

jQuery that handles submission:

$('.locate-distributors-form').on('submit', function(e) {
  $this = $('.locate-distributors-form');
  geocoder = new google.maps.Geocoder;
  var address = $('input[name=origin]').val();
  geocoder.geocode({ 'address': address }, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK) {
      var latLng = results[0].geometry.location;
      var locationToSubmit = { location: { lat: latLng.lat(), lng: latLng.lng() }, radius: $('select[name=radius]').val() };
        url: $this.attr('action'),
        type: 'POST',
        data: locationToSubmit,
        success: function(data) {
          // success function
    } else {
      // error text

When we pass in, for instance, "Toronto", the locationToSubmit object equals:

  location: {
    lat: 43.653226,
    lng: -79.38318429999998 
  radius: "50"

The action that is accepting the submission looks like this:

public ActionResult LocateDistributors(Location location, int radius = 50)
    DistributorLocatorViewModel model = new DistributorLocatorViewModel();
    model.Origin = location;
    model.Distributors = locateDistributors(location, radius);

    return Json(model, JsonRequestBehavior.AllowGet);

And, finally, the Location class is defined as:

public class Location
    public double Lat { get; set; }
    public double Lng { get; set; }

Related posts

Recent Viewed