Custom Error Page Asp.net Web.config
here 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 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 Implementing a Custom Error page on an ASP.Net website up vote 8 down vote favorite 2 I have an ASP.Net website and I want to use a custom error page. I put the following code in my web.config
ASP.NET Community Standup Forums Help Home/ASP.NET Forums/General ASP.NET/Configuration and Deployment/Web Config
you're not alone. It's surprisingly difficult to do this correctly, not helped by the fact that some errors are http://benfoster.io/blog/aspnet-mvc-custom-error-pages handled by ASP.NET and others by IIS. Ideally (and I expect http://www.codeproject.com/Articles/2345/Custom-Errors-in-ASP-NET such is the case with some other frameworks/servers) we would just configure our custom error pages in one place and 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 MVCLatest Articles Latest Tips/Tricks Top Articles Beginner Articles Technical Blogs Posting/Update Guidelines Article Help Forum Article Competition Submit an article or tip Post your Blog quick answersQ&A Ask a Question about this article Ask a Question View Unanswered Questions View All Questions... C# questions Linux questions ASP.NET questions SQL questions VB.NET questions discussionsforums All Message Boards... Application Lifecycle> Running a Business Sales / Marketing Collaboration / Beta Testing Work Issues Design and Architecture ASP.NET JavaScript C / C++ / MFC> ATL / WTL / STL Managed C++/CLI C# Free Tools Objective-C and Swift Database Hardware & Devices> System Admin Hosting and Servers Java .NET Framework Android iOS Mobile SharePoint Silverlight / WPF Visual Basic Web Development Site Bugs / Suggestions Spam and Abuse Watch features Competitions News The Insider Newsletter The Daily Build Newsletter Newsletter archive Surveys Product Showcase Research Library CodeProject Stuff communitylounge Who's Who Most Valuable Professionals The Lounge The Insider News The Weird & The Wonderful The Soapbox Press Releases Non-English Language > General Indian Topics General Chinese Topics help What is 'CodeProject'? General FAQ Ask a Question Bugs and Suggestions Article Help Forum Site Map Advertise with us About our Advertising Employment Opportunities About Us Articles » Web Development » ASP.NET » General ArticleBrowse CodeStatsRevisionsAlternatives Comments (18) Add your ownalternative version Tagged as VBWindows.NET.NET1.0Visual-StudioASP.NETDev Stats 349.6K views99 bookmarked Posted 27 May 2002 Custom Errors in ASP.NET Amit Kukreja, 27 May 2002 4.36 (32 votes) 1 2 3 4 5 4.36/5 - 32 votes2 removedμ 3.96, σa 1.74 [?] Rate this: Please Sign up or sign in to vote. In this article I will talk about customizing the defau