Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Classic ASP - Custom Error Pages

I have a clean install of Windows Server 2008 with IIS7. There I installed "Classic ASP" and the changed the debugging option "Send Errors To Browser" to True.

1.

I created a directory with 2 files:

-- C:\inetpub\wwwroot\stadtbibliothek
 - index.asp -> <% Response.Write "Hello World" %>
 - 500-100.asp -> <% Response.Write "Error" %>

I konverted the directory to an application and assigned a application pool i created (.net version: no managed code, pipelinecode: classic).

Then I tested the page from an remote client (http://svr-name.domain/stadtbibliothek/) and "Hello World" showed up.

2.

I added an error to the index.asp file and a web.config file to the "stadtbibliothek" folder (there is none in the root):

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <defaultDocument>
            <files>
                <add value="index.asp" />
            </files>
        </defaultDocument>
                <httpErrors>
                    <remove statusCode="500" subStatusCode="100" />
                    <error statusCode="500" subStatusCode="100" prefixLanguageFilePath="" path="/error.asp" responseMode="ExecuteURL" />
                </httpErrors>
    </system.webServer>
</configuration>

Solution:

Turned out I just needed to include the folder name to the path:

<error statusCode="500" subStatusCode="100" prefixLanguageFilePath="" path="/stadtbibliothek/error.asp" responseMode="ExecuteURL" />

Thanks for your suggestions!

like image 863
John Avatar asked Oct 02 '22 05:10

John


1 Answers

From the documentation:

path: Required string attribute.

Specifies the file path or URL that is served in response to the HTTP error specified by the statusCode and subStatusCode attributes. If you choose the File response mode, you specify the path of the custom error page. If you choose the ExecuteURL response mode, the path has to be a server relative URL (for example, /404.htm). If you choose the Redirect response mode, you have to enter an absolute URL (for example, www.contoso.com/404.htm).

Try changing this line:

<error statusCode="500" subStatusCode="100" prefixLanguageFilePath="" path="/error.asp" responseMode="ExecuteURL" />

To this:

<error statusCode="500" subStatusCode="100" prefixLanguageFilePath="" path="/stadtbibliothek/error.asp" responseMode="ExecuteURL" />
like image 71
Salman A Avatar answered Oct 13 '22 10:10

Salman A