My Controller can create a model object, but all properties associated with the model are assigned to null values
Environment: VS 2010, ASP.NET MVC RC latest, jQuery 1.7.1
Below is the web API controller code
public class Customer { public string Name { get; set; } public string City { get; set; } } public class UserController : ApiController { public Customer Post(Customer user) { return user; } }
Below is the ajax call code
$.ajax('/api/user', { ContentType: "application/x-www-form-urlencoded; charset=UTF-8", dataType: 'json', type: 'POST', data: JSON.stringify({ "Name": "Scott", "City": "SC" }) });
The controller creates an object of the "Client" model, but the "Name" and "City" properties are equal to zero.
What is wrong here?
I read a lot of similar questions on this site, but could not find a solution.
source share