1
votes

At witts end with this problem.

I am working on a busy site which we have migrated from IIS6 to IIS7, which uses a custom 404.asp handler to process SEO friendly URLS and return the correct content from included asp scripts.

We have managed to get the 404 method to work on IIS7, but if there is a error in the code somewhere, we have set iis to run 500.asp which is designed to log the error and returns a useful message to the user.

So the flow should be :

User types Friendly URL : e.g. http://www.sitename.com/testarticle/ Which does not exist and fires 404.asp 404 looks up "testarticle" in our database and returns the correct content. That all works..

If error Should call 500.asp - Logs Error in our Log (Works) - Returns Msg to the screen (Not working - Just Get Blank Page)

This worked in IIS6, however in IIS7 the 500.asp logs the error in our log, but absolutely nothing is written out to the screen - We just get a blank screen. Very Frustrating.

We have tried changing what feels like every setting in IIS, and web.config but we can't get this to work.

Any help much appreciated.. Cheers

2

2 Answers

2
votes

I did a similar migration a little while ago and this is the web.config settings I ended up with (well just the relevant parts):

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <httpErrors errorMode="DetailedLocalOnly">
            <remove statusCode="404" subStatusCode="-1" />
            <error statusCode="404" subStatusCode="-1" prefixLanguageFilePath="" path="/common/404.asp" responseMode="ExecuteURL" />
            <remove statusCode="500" subStatusCode="100" />
            <error statusCode="500" subStatusCode="100" prefixLanguageFilePath="" path="/common/500.asp" responseMode="ExecuteURL" />
        </httpErrors>
    </system.webServer>
</configuration>

Note the web.config section used. When done using the customErrors element it did not work for me. This was the only way I could get both URL rewriting using a custom 404 error page and custom 500 errors working in Classic ASP. Hopefully that helps you.

0
votes

So you get a blank page? 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 ;)