title: MVC3. Browser alerts by itself when returning 500 status code
body: <p>Hello how to prevent browser from alerting by itself, when returning a  <code>HttpStatusCodeResult</code> object.</p>
  <p>The Action Method:</p>
  <pre><code>    [HttpPost]
      public ActionResult Finish()
      {
          //Throw the status code result          
          return new HttpStatusCodeResult(500,&quot;Oops something wrong happened!&quot;);
      }
  </code></pre>
  <p>The script</p>
  <pre><code>           jQuery.ajax({
                  url: '@Url.Action(&quot;Finish&quot;,&quot;Home&quot;)',
                  type: &quot;POST&quot;,
                  success : function(result) {
                      alert(&quot;success is:&quot;+result);
                  },
                  error: function (response, status, errorThrown) {
                      alert(errorThrown);
                  }
              });
  </code></pre>
  <p>The result of calling <strong>Finish()</strong> Action is displayed in the <code>alert();</code> function, but
  under the custom alert,
  <strong>The browser also alerts with a message</strong> - &quot;<em>The page cannot be displayed because an internal server error has occurred.</em>&quot;</p>
  <h2>SOLUTION</h2>
  <p>The actual problem was, as #tanathos pointed out, a global function:</p>
  <pre><code>jQuery(document).ajaxError(function (e, jqxhr, settings, exception) {
  if (jqxhr != null) {
      alert(jqxhr.responseText);
  }
  </code></pre>
  <p>Thank you very much for your help. Question Closed.</p>