title: Return JSON with error status code MVC
body: <p>I was trying to return an error to the call to the controller as advised in
  <a href="https://stackoverflow.com/questions/6010368/how-does-json-determine-a-success-from-an-error">This link</a> so that client can take appropriate action. 
  The controller is called by javascript via jquery AJAX. I am getting the Json object back only if I don't set the status to error.
  Here is the sample code</p>
  
  <pre><code>if (response.errors.Length &gt; 0)
     Response.StatusCode = (int)HttpStatusCode.BadRequest;
  return Json(response);
  </code></pre>
  
  <p>I get the Json if I don't set the statuscode.
  If I set the status code I get the status code back but not the Json error object.</p>
  
  <p><strong>Update</strong>
  I want to send an Error object as JSON so that it can be handled error callback of ajax.</p>