0 Comments

If you want to sent arbitrary JSON data to a MVC controller action method, you can use the following code:

[HttpPost]
public ActionResult HandleRequest()
{
    // Read the RAW JSON from the request, 
    // because MVC does not support a dynamic input parameter or an input parameter of type JObject.
    // ASP .NET Web API does support a dynamic input parameter or an input parameter of type JObject.
    string json = new StreamReader(this.Request.InputStream).ReadToEnd();
    dynamic clientData = JObject.Parse(json);

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Posts