Asp Net Friendly Error Page
Contents |
you're not alone. It's surprisingly difficult to do this correctly, not helped by the fact that some errors are handled by
Asp.net Mvc Error Handling
ASP.NET and others by IIS. Ideally (and I expect such is the asp.net custom error case with some other frameworks/servers) we would just configure our custom error pages in one place and asp.net error handling it would just work, no matter how/where the error was raised. Something like:
404 Page Not Found
I created a new ASP.NET MVC 5 application using the standard template in Visual Studio. If I run the site and try to navigate to a resource that does not exist e.g. /foo/bar, I'll get the standard ASP.NET 404 page with the following information: Server Error in '/' Application. The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly. Requested URL: /foo/bar Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.33440 Not exactly friendly, is it? In this case the error was raised by ASP.NET MVC because it could not find a matching controller and/or action that matched the specified URhere for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn http://stackoverflow.com/questions/17957954/how-can-i-make-a-custom-error-page-in-asp-net-web-pages-with-webmatrix more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up How can I make a custom error page in ASP.NET web-pages with WebMatrix? up vote 5 down vote favorite Believe it or not I tried asp net to look for the answer to this question with a simple Google Search but I didn't find anything (Googled with "WebMatrix custom error page", "WebMatrix how to make custom server-side error page", etc.), but perhaps I am not searching with the correct terms... Anyway, I was just wondering if there was a way (I believe it involves the web.config file) to show a custom-made error page instead of ANY server-side error page. I know there is custom error page a way to do this with some pages (like 404 or 500) but is it possible to make a catch all page for any server-side error? (I guess 404 wouldn't work, since it has to find your site to show any custom page?) Please forgive me if this is a repeat question, but my lack of knowledge in doing this has possibly left me without the correct search terms to search on, although I have tried searching SE, as well. asp.net web-config webmatrix custom-error-pages asp.net-webpages share|improve this question asked Jul 30 '13 at 21:42 VoidKing 2,51243063 add a comment| 1 Answer 1 active oldest votes up vote 8 down vote accepted Add the following to your web.config file within the