Hi I have an action in my controller, i am waiting to ModelBinder bind the incoming postdata to my action parameter but it doesnt do this, i dont know. I only manually bind them with TryUpdateModel() but i dont want to use it. Property names and the postdata are the same why it cant bind them ?
public class User
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string Username { get; set; }
public string Password { get; set; }
}
public ActionResult Update(User user)
{
// TODO
}
My javaScript Code that send data to my Action:
newData = {
"FirstName":"Yucel"
"LastName": "Akpınar",
"Email": "yucelakpinar",
"Password": "123456"
};
$.ajax({
type: "POST",
dataType: "json",
data: newData,
url: "/Profile/Update",
success: function() {
debugger;
}
});
The reason it isn’t working is because the payload of your request is a JSON object, which the current model binder isn’t capable of parsing (actually the model binder doesn’t retrieve any of its values, the value provider does). We’ve made this scenario possible in v2, but for it to work in v1 you’d have to add support for it yourself.