Chapter 5. ASPError Object

Introduced with ASP 3.0, the built-in ASPError object allows you to view detailed information about the last error that occurred in the script of an ASP page in the current session. This object, through its nine read-only properties, provides more detailed information about the type and source of errors than does the Err object provided in VBScript.

To use the ASPError object and its properties, you must call a new method of the Server object, GetLastError, which returns an ASPErrorObject with its properties' values set to reflect details about the last error that occurred in the script:

Dim objMyASPError
Set objMyASPError = Server.GetLastError

When you install IIS 5.0, by default, all preprocessing, script and runtime errors in ASP code cause IIS to stop processing the current script and redirect script execution to a custom error page named 500-100.ASP. This redirection occurs through an internal call to the Server.Transfer method which, as detailed in Chapter 9, shifts execution from one script to another while protecting all state information available in the first script.

The 500-100.ASP script (located by default in the C:\WINNT\Help\iisHelp\common directory) contains a call to the Server.GetLastError method. When this script is executed, it formats and displays the current property values of the ASPError object returned by this call to GetLastError.

You can use the default error page, 500-100.ASP, as-is; edit it to reflect your site's look and feel; ...

Get ASP in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.