title: Controller.OnException is called but returns error 500,only in production
body: <p>I'm having a strange behaviour in my Asp.Net MVC application. I have overriden OnException method in my controller to handle errors:</p>
  
  <pre><code>protected override void OnException(ExceptionContext filterContext)
  {
      var action = filterContext.RouteData.Values["action"].ToString();
      var type = filterContext.Controller.GetType();
      var httpMethod = filterContext.RequestContext.HttpContext.Request.HttpMethod;
      filterContext.ExceptionHandled = true;
  
      var returnType = GetReturnType(type, action, httpMethod);
      if (returnType == typeof(JsonResult))
          filterContext.Result = HandleJsonError(filterContext.Exception);
      else
          filterContext.Result = HandleError(filterContext.Exception);
  }
  </code></pre>
  
  <p>The code above identify if the method called is a normal view result or a jsonResult, and show a error page or return the error message in json. If its Json, it returns something like that:</p>
  
  <pre><code>{"OK":false,"ErrorMessage":"Error message to the user"}
  </code></pre>
  
  <p>So, when an error occurrs, the browser receives a HTTP 200 code, like there was no error, but in my client code I identify the error message and show it to the user. </p>
  
  <p>This is working fine on my development environment, but when I uploaded it to production, the async request is returning a HTTP 500 error, but the returned content is still the same JSON. That means that OnException is still called, but returns a 500 code instead of 200. How can i make it reuturn 200 on the production?</p>