I tried the solution below without success. In the controller method MvcAction
, the prs
parameter is always null. Below is the code I'm using to call the controller method.
function getPerson() {
var jFirstName = '@Model.Person.FirstName';
var jLastName = '@Model.Person.LastName';
return { FirstName: jFirstName, LastName: jLastName };
}
var person = getPerson();
var jsonPerson = JSON.stringify(person);
$.post( '@Url.Action("MvcAction", "MvcXontroller")', { prs : jsonPerson },
function( data ) {
....
});
The action method look like this:
public void MvcAction(Person prs)
{
}