How to get Custom Error Pages working for Classic ASP with IIS 7 Integrated Pipeline


I'm working on a website with legacy Classic ASP pages (being converted to ASP.NET on an as needed basis) and new ASP.NET pages. Use of IIS 7 Integrated Pipeline has been very helpful with our configuration. For example, we were able to get forms authentication working auto-magically with the classic ASP pages simply by configuring the appropriate sections of the web.config file (i.e. no changes were required to the Classic ASP pages, for more info see this).

A colleague of mine believes that custom error pages, as specified in the web.config <customErrors> section, should also be auto-magically applied to the classic ASP pages, but for our website it only works for the ASP.NET pages. Nor have I been able to find any information describing the capability of applying custom error pages to Classic ASP with the IIS 7 integrated pipeline.

Is it possible to apply custom error pages to Classic ASP pages per a web.config for an website running under IIS7 with integrated pipeline? If so, how?

Best Solution

The IIS7 custom error pages are handled in the <system.webServer> configuration section not the <customErrors> section under <system.web> which applies to ASP.NET only:

               responseMode="ExecuteURL" />

Beware though of these settings conflicting with ASP.NET custom errors. If you're running .NET 3.5 and above you can set Response.TrySkipIisCustomErrors in your ASP.NET error page code-behind (or error controller if using MVC) to prevent IIS overriding your ASP.NET error page(s):

Response.TrySkipIisCustomErrors = true // ASP.NET Forms

This article by Rick Strahl explains this problem in a bit more depth:

IIS 7 Error Pages taking over 500 Errors