I'm trying to send a json serialized object through a form to a c# MVC action.
var object = {
id: 1,
field1: "",
field2: "",
.
.
.
}
var inputs = "<input type'hidden' name='serializedObject' value='" + JSON.stringify(object) + "'/>";
$("<form action='actionUrl' method='POST' >" + inputs + "</form>").appendTo("body").submit().remove();
Server side I have an action that take stringified object and parse them:
[HttpPost]
public virtual FileResult TestAction(string serializedObject){
//...do stuff....
}
But in the action I don't receive the entire json string (I have to use form and not ajax because I have to download a file).
var url = '/../TestAction?id=1&field1=someValue&field2=anotherValueetc and uselocation.href=url;where the method isFileResult TestAction(int id, string field1, etc)