I have read quite some blogs and stackoverflow answers on how to send a JavaScript object to an asp.net MVC controller. But all examples I have seen so far require you to know which properties the JavaScript object will have (because they all convert the JavaScript object to a C# object).
When I was using PageMethods in asp.net webforms I could send any complex JavaScript object or array (even hierarchical data) and it would be converted to a Dictionary which I could iterate. Any chance I can do something similar in asp.net MVC?
I now found a way which works for me.
JavaScript code:
Server side code:
The good thing: it is “normal” json which means it is not some uncommon format or interface-type.
EDIT: I found out that I don’t even need the C# json-library if I am using .net 4 – since I can convert any json string to a Dictionary with the help of the JavaScriptSerializer: