I have tried about everything I can find on google to get a custom 500 error page for my MVC3 app to work, with absolutely no success. Does anyone have a response with an absolute, de-facto way to get MVC3 custom error pages and IIS 7.5 work gracefully?
I either get the standard IIS 500 page or get a detailed ASP.NET error page when IIS chooses to ignore my customError mode="On" half the time. RIDICULOUS how much time is spent on something so relatively simple!
I have finally got it to work. While your replies got me in the right direction, and thank you for your suggestions, none of the solutions were solid enough to cover everything needed to be done/considered.
And here's a handy-dandy little piece of information... did you know that Internet Exploder (don't even get me started on the amount of time spent specifically coding to get things right on that trash browser) won't show your error page if it is under 512
bytes? That's right, even if you have done EVERYTHING right in configuring things you will continue to pull your hair out trying to figure out why the little test error page you made (because you had spent so much time trying to get the dang thing to show,
you didn't feel the need to spend time designing one until you found a worthy solution) won't show and instead you will continue to get a default 500 page. I hope this saves a lot of headaches for anyone who is running into the same problem.
codegirlcode...
Member
50 Points
21 Posts
Custom 500 Error Page with MVC3 / IIS 7.5 Can not get to work!
Mar 19, 2012 05:05 PM|LINK
I have tried about everything I can find on google to get a custom 500 error page for my MVC3 app to work, with absolutely no success. Does anyone have a response with an absolute, de-facto way to get MVC3 custom error pages and IIS 7.5 work gracefully? I either get the standard IIS 500 page or get a detailed ASP.NET error page when IIS chooses to ignore my customError mode="On" half the time. RIDICULOUS how much time is spent on something so relatively simple!
MVC3 app on Windows Server 2008 R2 w/ IIS 7.5
DarrellNorto...
All-Star
86685 Points
9634 Posts
Moderator
MVP
Re: Custom 500 Error Page with MVC3 / IIS 7.5 Can not get to work!
Mar 20, 2012 09:47 AM|LINK
IIS will override for "common" errors like HTTP 404 and 500.
Try setting Response.TrySkipIisCustomErrors = true before setting the Response.StatusCode to 404 or 500.
See this blog post for an example: http://blog.janjonas.net/2011-04-13/asp_net-prevent-iis_75_overriding-custom-error-page-iis-default-error-page
Darrell Norton's Blog
Please click "Mark as Answer" if this helped you.
ricka6
All-Star
15070 Points
2272 Posts
Microsoft
Moderator
Re: Custom 500 Error Page with MVC3 / IIS 7.5 Can not get to work!
Mar 20, 2012 04:48 PM|LINK
http://blog.davebouwman.com/2011/04/21/custom-404-pages-for-asp-net-mvc-3/
http://www.west-wind.com/weblog/posts/2009/Apr/29/IIS-7-Error-Pages-taking-over-500-Errors
codegirlcode...
Member
50 Points
21 Posts
Re: Custom 500 Error Page with MVC3 / IIS 7.5 Can not get to work!
Mar 21, 2012 08:34 PM|LINK
I have finally got it to work. While your replies got me in the right direction, and thank you for your suggestions, none of the solutions were solid enough to cover everything needed to be done/considered.
Most of my workable solution was from following this: http://blog.janjonas.net/2011-12-11/asp-net-mvc3-custom-error-pages-non-ajax-requests-jquery-ajax-requests. However, I chose not to use partial views(and ignored the AJAX stuff -- not applicable for me at the time). Also, I had to modify the redirect attributes in the <customError><error> tags
To:
And here's a handy-dandy little piece of information... did you know that Internet Exploder (don't even get me started on the amount of time spent specifically coding to get things right on that trash browser) won't show your error page if it is under 512 bytes? That's right, even if you have done EVERYTHING right in configuring things you will continue to pull your hair out trying to figure out why the little test error page you made (because you had spent so much time trying to get the dang thing to show, you didn't feel the need to spend time designing one until you found a worthy solution) won't show and instead you will continue to get a default 500 page. I hope this saves a lot of headaches for anyone who is running into the same problem.
ricka6
All-Star
15070 Points
2272 Posts
Microsoft
Moderator
Re: Custom 500 Error Page with MVC3 / IIS 7.5 Can not get to work!
Mar 22, 2012 09:02 PM|LINK
SO FAQ
Custom error pages on asp.net MVC3
Thanks for posting the answer. I guess you learned the lesson (don't test with just IE). I had no idea of that limitation.