title: ASP.NET MVC JsonResult not returning responseText in jQuery.post fail callback function
body: <p>I am using jQuery <code>$.post</code> to post some data to an ActionResult method inside my controller. When an error is thrown in the controller, it should return the error message within the responseText of the response but it's not working.</p>
  
  <p>The post request is hitting the controller.</p>
  
  <p>The callback function <code>fail</code> seems to be triggered. Just not getting the error message returned. Not sure what I am doing wrong?</p>
  
  <p>This is jQuery posting data:</p>
  
  <pre><code>var postData = ["1","2","3"];
  
  $.post('/MyController/GetSomething', $.param(postData, true))
        .done(function (data) {
                alert('Done!');                        
        })
        .fail(function (xhr, textStatus, errorThrown) {
                alert(xhr.responseText); //xhr.responseText is empty   
        });
   });
  </code></pre>
  
  <p>Controllers</p>
  
  <pre><code>
      public class MyController : BaseController
      {
          public ActionResult GetSomething(List ids)
          {
              try
              {
                  GetSomeData(ids);
              }
              catch (Exception ex)
              {
                  return ThrowJsonError(new Exception(String.Format("The following error occurred: {0}", ex.ToString())));
              }
  
              return RedirectToAction("Index");
          }
      }
  
      public class BaseController : Controller
      {
          public JsonResult ThrowJsonError(Exception ex)
          {
              Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest;
              Response.StatusDescription = ex.Message;
  
              return Json(new { Message = ex.Message }, JsonRequestBehavior.AllowGet);
          }
      }
  
  </code>
  </pre>
  
  <p><strong>Update</strong>
  What's interesting is that if I move some of the logic from out of the BaseController and into the MyController, I am able to get the desired result.</p>
  
  <p>Why would this happen?</p>
  
  <pre><code>public class MyController : BaseController
      {
          public ActionResult GetSomething(List&lt;string&gt; ids)
          {
              try
              {
                  GetSomeData(ids);
              }
              catch (Exception ex)
              {
                  Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest;
                  Response.StatusDescription = ex.Message;
  
                  return Json(new { Message = ex.Message }, JsonRequestBehavior.AllowGet);
              }
  
              return RedirectToAction("Index");
          }
      }
  </code></pre>