title: ASP Mvc 3 wont autobind from JSON post request
body: <p>I have got a simple controller:</p>
  
  <pre><code>public class UserCredentials
  {
     public string Username {get;set;}
     public string Password {get;set;}
  }
  
  public class AuthenticationController : Controller
  {
      public ActionResult Authenticate(UserCredentials credentials)
      {
          // Do stuff
      }
  }
  </code></pre>
  
  <p>And a simple bit of Jquery:</p>
  
  <pre><code>var credentials = {
      Username: "test",
      Password: "test"
  };
  
  $("#send-request").button().click(function() {
      var ajaxOptions = {
          url: "http://localhost:29097/authentication/",
          type: "POST",
          dataType: 'json',
          data: JSON.stringify(credentials),
          contentType: "application/json; charset=utf-8",
          success: function(result) { $("#result").html(result); }
      };
      $.ajax(ajaxOptions);
  });
  </code></pre>
  
  <p>Whenever I click the button on the page to send over the request, the UserCredentials object contains null for both properties... I have tried posting directly via fiddler with JSON, no luck there either... do I need to do anything special to get this working?</p>
  
  <p>-- EDIT --</p>
  
  <p>I have been double checking and it seems that when the data leaves the client it has the json data correctly within the header. However when fiddler picks it up it doesn't seem to contain the data, it looks like it is doing an OPTIONS call:</p>
  
  <pre><code>OPTIONS http://localhost:29097/authentication/ HTTP/1.1
  Host: localhost:29097
  User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1
  Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
  Accept-Language: en-gb,en;q=0.5
  Accept-Encoding: gzip, deflate
  Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
  Keep-Alive: 115
  Connection: keep-alive
  Origin: null
  Access-Control-Request-Method: POST
  Access-Control-Request-Headers: content-type,x-requested-with
  </code></pre>
  
  <p>If it helps I am running the MVC app via the Development Server (think its called Cassini)</p>