My action method used to have one parameter, and I didn't have any problem to pass model to it.
public ActionResult actionMethod([Bind(Exclude = "pro1, pro2")] Class model)
And the Ajax call:
var formData = $('form').serialize();
$.ajax({
url: "@Url.Action("actionMethod", "controller")",
method: 'post',
data: { header: formData},
success: function (result) {
.....
}
});
It worked fine, until I had to add another parameter to the method:
public ActionResult actionMethod([Bind(Exclude = "pro1, pro2")] Class model, string anotherParam = "1")
And I'm trying with this Ajax call:
var formData = $('form').serialize();
$.ajax({
url: "@Url.Action("actionMethod", "controller")",
method: 'post',
data: {
header: formData,
anotherParam: '1'
},
success: function (result) {
.....
}
});
And it doesn't work anymore, the model is always null. How should I pass these data?