title: Passing Json data to MVC controller - Action Method's JObject Parameter
body: <p><em>Sorry for the wrong formatting or spelling. As i am writting this post in hurry. :)</em> </p>
  
  <p>I am passing json data to action method of simple controller (MVC controller). Here is the below sample code for reference. </p>
  
  <p><strong>JS CODE:</strong> </p>
  
  <p>var json = {IsInit :true, SearchParam:{ Type:"xx",Name:"xx",sort: ""} };</p>
  
  <pre><code>    Nx$(document).ready(function () {
  
          Nx$.ajax({
              async: true,
              contentType: "application/json; charset=utf-8",
              type: "POST",
              url: "Home/Data",
              dataType: "json",
              data: JSON.stringify(json),
              success: function (msg) {
                  alert('success');
              },
              error: function (jqxhr, textStatus, error) {
                  alert('fail');
              }
          });
  </code></pre>
  
  <p><strong>Action Method :</strong> </p>
  
  <pre><code>&lt;HttpPost&gt;
          &lt;Route("Data")&gt;
          Function GetData(ByVal IsInit As Boolean, ByVal SearchParam As Newtonsoft.Json.Linq.JObject) As ActionResult
              Return Nothing
          End Function
  </code></pre>
  
  <p>Now, above action doesn't call at all. but if you use below code then it makes the call but SearchParam is of type [object] only and you can not use any value of searchParam object.</p>
  
  <pre><code>&lt;HttpPost&gt;
      &lt;Route("Data")&gt;
      Public Function GetData(ByVal IsInit As Boolean, ByVal SearchParam As Object) As Object
          Return Nothing
      End Function
  </code></pre>
  
  <p>I think that it does not able to pass multiple parameter in POST request with complex json object. </p>
  
  <p>How can i get JSON data passed to MVC controller's action method so that SearchParam Json data converted to JObject it self. i.e. initial first Action method signature should be used with out any major method signature changes.</p>
  
  <p>Few Observation :</p>
  
  <ol>
  <li><p>if i turned above action method as api in API Controller; it start working but having said that you need to follow the below method signature. below approach is not working for MVC controller. Don't know why ?? However, For Some reason; i can not go with API controller.</p>
  
  <pre><code>    &lt;HttpPost&gt;
      &lt;Route("Data")&gt;
      Function GetData(ByVal req As Newtonsoft.Json.Linq.JObject) As ActionResult
          Return Nothing
      End Function
  </code></pre></li>
  </ol>
  
  <p>Thanks !!</p>