title: Send data to MVC controller using JSON
body: <p>I am using JQuery Ajax to make a simple call to an ASP.NET MVC controller. Here is my code</p>
  
  <pre><code>   function postdata(idno) {
     console.log(idno);
  
     $.ajax({
          type: 'POST',
          url: "/IM/GetMessages",
          contentType: 'application/json',
          dataType: 'json',            
          data: JSON.stringify({ 'fUserId': idno }), 
          success: function (data) { /*CODE*/
  
      });}
  </code></pre>
  
  <p>The controller looks like this</p>
  
  <pre><code>     [HttpPost]
       public ActionResult GetMessages(decimal? fUserId)
       {
          var list = WebUtility.IMMessages.Where(p =&gt;
              (p.ToUserId == Session.UserId  &amp;&amp; (!fUserId.HasValue || fUserId.HasValue &amp;&amp; p.User == fUserId.Value)))
              .OrderBy(p =&gt; p.CreatedDateTime)
              .Select(p =&gt; new { MessageId = p.RecordId, MessageBody = p.Description1 });
  
          return Json(list, JsonRequestBehavior.AllowGet);
       }
  </code></pre>
  
  <p>The <strong>problem</strong> is that my data doesn't pass to my controller, "null" passes instead. how can I correct this issue? I am watching "idno" on console and everything seems to be OK.</p>