MVC controller : get JSON object from HTTP body?

前端 未结 5 557
闹比i
闹比i 2020-11-28 06:46

We have an MVC (MVC4) application which at times might get a JSON events POSTed from a 3rd party to our specific URL (\"http://server.com/events/\"). The JSON event is in th

5条回答
  •  遥遥无期
    2020-11-28 07:35

    you can get the json string as a param of your ActionResult and afterwards serialize it using JSON.Net

    HERE an example is being shown


    in order to receive it in the serialized form as a param of the controller action you must either write a custom model binder or a Action filter (OnActionExecuting) so that the json string is serialized into the model of your liking and is available inside the controller body for use.


    HERE is an implementation using the dynamic object

提交回复
热议问题