MVC HandleError returns error 500 and view error page

2.9k views Asked by At

I am using MVC 3 with VS2010 and trying to get [HandleError] working. I created a test in the controller to simulate a crash as follows:

[HandleError]
public ActionResult Crash()
{
    throw new ApplicationException();
}

Also went into web.config and added:

<customErrors mode="on" />

If I run from Chrome, MVC returns the view in Shared/Error.aspx, so this work ok.

If I run from IE 8, I get its friendly error page ("The website cannot display the page, Most likely causes: ... What you can try..."). I went into IE Tools and turned off "Show friendly HTTP error message" and run again and IE shows my Error.aspx view. Obviously I can't get users to change this setting, but at least I know my Error.aspx is being returned.

So I run Fiddler, and when I make the browser go to my Crash method, it shows that that even though MVC is returning my Error.aspx view, it is returning 500 for the Result. This causes IE to think it has an error and override my page with its friendly page.

I think MVC should be returning Result 200 with my Error.aspx page and not 500. Can anyone give me some ideas on what to try?

1

There are 1 answers

0
Mark Simpson On BEST ANSWER

If you make your error page > 512 bytes, it should work fine. It's just IE being an inconsiderate swine, as ever.