title: Ajax Request returns HTTP error 500, using MVC and $.ajax call with POST?
body: <p>I've seen several threads about this, and I've tried all the answers (<a href="https://stackoverflow.com/questions/3113952/asp-net-mvc-jsonresult-return-500">ASP.NET MVC JsonResult return 500</a>)</p>
  <p>My ajax request is re-turning a 500 Internal Error. If I debug I never even get to my action.</p>
  <p>Here is my ajax call:</p>
  <pre><code>$.ajax({
                      url: '@Url.Action(&quot;UpdateSortOrder&quot;, &quot;FormItems&quot;)',
                      data: { itemToUpdateId: item.attr(&quot;id&quot;), newParentItemId: parentItemId, newPreviousItemId: previousItemId },
                      type: 'POST',
                      success: function (data) {
                          console.log(data);
                      },
                      error: function (xhr, status, exception) {
                          console.log(&quot;Error: &quot; + exception + &quot;, Status: &quot; + status);
                      }
                  });
  </code></pre>
  <p>And my action:</p>
  <pre><code>[HttpPost]
      public ActionResult UpdateSortOrder(Guid itemToUpdateId, Guid newParentItemId, Guid newPreviousItemId)
      {
          FormItem updatedItem = _formItemService.GetOne(x =&gt; x.Id == itemToUpdateId);
  
          return Json(updatedItem, JsonRequestBehavior.DenyGet);
      }
  </code></pre>
  <p>Using chrome console, these are the response headers from the reply:</p>
  <blockquote>
  <p>HTTP/1.1 500 Internal Server Error
  Cache-Control: private
  Content-Type: text/html; charset=utf-8
  Server: Microsoft-IIS/7.5
  X-AspNetMvc-Version: 3.0
  X-AspNet-Version: 4.0.30319
  X-Powered-By: ASP.NET
  Date: Tue, 18 Dec 2012 21:53:41 GMT
  Content-Length: 17041</p>
  </blockquote>
  <p>Server logs show no substatus codes. Any idea what I am doing wrong here? I've prefer to use POST instead of GET.</p>
  <p>The Form Data is being shown as :</p>
  <blockquote>
  <p>itemToUpdateId:18ac5399-342e-4a39-9da1-3281a89501df</p>
  <p>newParentItemId:null</p>
  <p>newPreviousItemId:null</p>
  </blockquote>
  <p>Which is correct.</p>
  <p>I've tried setting the contentType to application/json and traditional = true like in this question: <a href="https://stackoverflow.com/questions/11606449/sending-ajax-post-to-mvc-with-application-json-charset-utf-8-returns-error-50">Sending ajax post to mvc with &quot;application/json; charset=utf-8&quot; returns error 500 from vs web developer server</a></p>
  <p>Same error.</p>