1

I'm trying to implement this accepted solution for displaying a custom error message:

https://stackoverflow.com/a/5229581/141172

However, IE9 always displays a generic 500 error message with this solution. Google Chrome displays my custom error message.

Making this change:

Response.StatusCode = 200; // don't return: 500

causes the intended behavior in IE9 and Chrome.

However, it does not seem at all reasonable to change the HTTP status code just to make this work in IE9 (for one, website monitoring solutions would not see the 500 if things fail).

How can I add custom error handling in a manner that will work across all browsers, without changing the HTTP status code?

Community
  • 1
  • 1
Eric J.
  • 147,927
  • 63
  • 340
  • 553

1 Answers1

3

Apparently, IE will ignore a custom error page if it's smaller than 512 bytes. The workaround is to ensure the page has at least 513bytes of data. Also, if you're using gzip compression, it must be more than 512 bytes AFTER compression.

Erik Funkenbusch
  • 92,674
  • 28
  • 195
  • 291
  • To test this, I added the following to my code: `throw new IReallyWantToFinallyLikeIEButCantException("Why, oh why!");` – Eric J. Apr 09 '12 at 05:26
  • 1
    Note: Wikipedia claims this behavior was prior to IE7. However, I have confirmed it in IE9. http://en.wikipedia.org/wiki/HTTP_404 – Eric J. Apr 09 '12 at 05:29
  • ah I was just going to post about the 512 bytes but wasn't sure if this was or was not still an issue. Thanks for confirming Eric. Rounds of +1 for all : ) – Adam Tuliper Apr 09 '12 at 05:56