So, it pretty much is all in the title. Basically, I want to send a JSON through JQuery from client to asp.net MVC. I’m wondering if it’s possible for it to receive (but not necessarily parse) any JSON I want to send from JQuery Ajax call, regardless of it’s type.. without me having a concrete type/model representation of it. (basically like a dynamic type?)
Doing this the regular way (with me declaring the passing argument as type Object) just brings about nulls, which was what I expected.
Basically, I want to do some kind of “reflection for JSON” type stuff when I receive it, and be able to get it’s properties through some kind of foreach loop and etc.
Thanks in advance. Any help would be great!
You could use an
IDictionary<string, object>as action argument. Just write a custom model binder that will parse a JSON request into it:which will be registered in
Application_Start:then you could have the following controller action:
to which you can throw anything: