I'm getting what I consider to be a weird binding issue in the ASP.NET MVC 4 RC Web API. I have a method intended to accept post requests from the client. The issue is that none of the parameters are binding when the post method is called, I get to my break point on the throw line and name, email are both null. If I change the type of the request to GET in the JavaScript, then the Get function below is called with parameters bound.
Why are the parameters failing to bind for the Post method, and how can I fix this?
send: function(evt) {
evt.preventDefault();
$.ajax( {
url: '/api/person',
data: this.model.toJSON(),
type: "POST",
dataType: "json",
success: function(data) {
console.log("Success");
},
error: function(data) {
console.log("Error");
}
});
}
The following is the controller actions:
public void Get(string name, string email) {
throw new NotImplementedException();
}
public void Post(string name, string email) {
throw new NotImplementedException();
}
Notes:
- I'm using all of the defaults for ASP.NET MVC 4 RC Web API (So the deserializer should be Json.NET)
- The Chrome network tab on the JS debugger shows the parameters in the form data on post correctly.