I'm attempting to transmit a JSON serialized object via a form to a C# MVC action.
var obj = {
id: 1,
field1: "",
field2: "",
.
.
.
}
var inputs = "<input type'hidden' name='serializedObject' value='" + JSON.stringify(obj) + "'/>";
$("<form action='actionUrl' method='POST' >" + inputs + "</form>").appendTo("body").submit().remove();
On the server side, I have an action that receives and parses the stringified object:
[HttpPost]
public virtual FileResult TestAction(string serializedObject){
//...do stuff....
}
However, in the action, I am not receiving the full JSON string (I must use a form and not AJAX because I need to download a file).