简体   繁体   中英

Finding Classic ASP errors in a custom 404 error page in IIS7

We are migrating some Classic ASP sites from an IIS6 box to a new Server 2008 box running IIS7.

We have been through a learning process with regard to custom errors and now have these working correctly and Server.GetLastError is now working.

The sites we are migrating use a bespoke CMS that utilises a custom 404.asp error page to pull content from a database depending on the URL. This, too, works perfectly.

However, when the 2 are combined (eg we have a 500 error on a page that runs via the custom 404 page) we receive a completely blank page. No error, no information nothing. Just a plain white page.

Example 1: http://snavebelac.com/thisdoesnotexist results in the custom 404 page Example 2: http://snavebelac.com/st-test blank page. This has an intentional 500 error within the custom 404 page.

I assume that because it is running through the custom 404.asp error page that this somehow blocks the custom 500 error page from functioning.

Does anyone know how I might be able to configure the sever so that the custom 404 page fires but 500 errors are output to the browser as they were in IIS6 OR is there a way to configure the server to process the custom 404 as well as the custom 500?

Thanks in advance.

Check out the solution posted here - How can I properly handle 404 in ASP.NET MVC?

The key is - Response.TrySkipIisCustomErrors = true;

I had a similar problem, the solution is really weird but works for sure.

I'll be very pragmatic, do the following.

<httpErrors errorMode="Custom" defaultResponseMode="ExecuteURL" existingResponse="Auto">
  <remove statusCode="500" subStatusCode="-1" />
  <error statusCode="500" subStatusCode="100" prefixLanguageFilePath="" path="/500.100.asp" responseMode="ExecuteURL" />
  <remove statusCode="404" subStatusCode="-1" />
  <error statusCode="404" prefixLanguageFilePath="" path="/404.asp" responseMode="ExecuteURL" />
</httpErrors>

The blank page will be "not blank" if you assure that it ends with:

Response.Flush()

When IIS executes the code inside /500.100.asp it doesn't flush the response and it ends with a blank page. I assure that "404" and "500.100" custom errors can be possible in IIS7.5/IIS8 and Classic ASP ;)

You have to configure your web.config to handle 500 status errors, like this:

<system.web>
    <customErrors mode="On" defaultRedirect="frmError.aspx">
        <error statusCode="404" redirect="frmNotFound.aspx" />
        <error statusCode="500" redirect="frmError.aspx" />
    </customErrors>
</system.web>

Note the fourth line of code, where you say witch page has to be invoked since you got a 500 error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM