ASPError Object

IIS 6.0

You can use the ASPError object to obtain information about an error condition that has occurred in script in an ASP page. The ASPError object is returned by the Server.GetLastError method. The ASPError object exposes read-only properties.

You can use the ASPError object in an ASP page that is configured to respond to an HTTP error. For more information about configuring custom errors, see Creating Custom Error Messages.

The ASPError object has no methods.

The ASPError object defines the following properties.

Property

Description

ASPError.ASPCode

Returns an error code generated by IIS.

ASPError.ASPDescription

Returns a more detailed description of the error, if it is an ASP-related error

ASPError.Category

Indicates if the source of the error was internal to ASP, the scripting language, or an object.

ASPError.Column

Indicates the column position within the .asp file that generated the error.

ASPError.Description

Returns a short description of the error.

ASPError.File

Indicates the name of the .asp file that was being processed when the error occurred.

ASPError.Line

Indicates the line within the .asp file that generated the error.

ASPError.Number

Returns the standard COM error code.

ASPError.Source

Returns the actual source code, when available, of the line that caused the error.

When IIS encounters an error either with compiling or running an .asp file, it will generate a 500;100 custom error. By default, all Web sites and applications will transfer processing of a 500;100 custom error to the default .asp file. After a 500;100 custom error is generated, IIS will also create an instance of the ASPError object that describes the error condition.

The following example demonstrates writing the information exposed by the ASPError object.

<%
    On Error Resume Next
    Set objASPError = Server.GetLastError
    Response.Write Server.HTMLEncode(objASPError.Category)
    If Len(CStr(objASPError.ASPCode)) > 0 Then
        Response.Write Server.HTMLEncode(", " & objASPError.ASPCode)
    End If
    Response.Write Server.HTMLEncode(" (0x" & Hex(objASPError.Number) & ")" ) & "<br>"
    If Len(CStr(objASPError.ASPDescription)) > 0 Then 
        Response.Write Server.HTMLEncode(objASPError.ASPDescription) & "<br>"
    ElseIf Len(CStr(objASPError.Description)) > 0 Then 
        Response.Write Server.HTMLEncode(objASPError.Description) & "<br>" 
    End If
%>

Client: Requires Windows XP Professional, Windows 2000 Professional, or Windows NT Workstation 4.0.

Server: Requires Windows Server 2003, Windows 2000 Server, or Windows NT Server 4.0.

Product: IIS

Show: