I am intentionally trying NOT to use a binding in the controller parameter, so I have a controller that looks like:
[HttpPost]
public ActionResult Untyp
The function serializeArray
creates a Javascript object with the form's key/value pairs. You don't want that, you want a single key/value with serializedformdata
= (JSON string). Ie, like this;
var formelements = { serializedformdata: JSON.stringify($('#form').serializeArray()) };
This passes the raw JSON string to the controller's parameter. You can use the JavaScriptSerializer
to get the object on the server:
var obj = (List<Dictionary<string,string>>)new JavaScriptSerializer().Deserialize(serializedformdata, typeof(List<Dictionary<string,string>>));
Dictionary<string,string> dict = obj.First();
string someval = dict["somekey"];