1
votes

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 (e.g. 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.

3
Should be no problem having custom 404s and custom 500s, both in classic asp, can you post the relevant part of your web.config?Richard Benson
An interesting problem I'm tried it myself on IIS7.5 and I get the same results.AnthonyWJones
Apologies for not replying to this sooner. We have not been able to find a solution other than adding "on error resume next" to the to the top of 404 page and then checking for "err" number at the end. This makes debugging very tricky though as the err info is somewhat lacking!Snavebelac

3 Answers

0
votes

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.

0
votes

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

The key is - Response.TrySkipIisCustomErrors = true;

0
votes

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 ;)