The ASP ASPError object contains read-only information about an error that has occurred on the server. The ASPError object is returned by the Server.GetLastError method.

  • Basic Usage
  • Properties
    • ASPCode. String for error code generated by IIS.
    • ASPDescription. String with more complete description of the error.
    • Category. String indicating whether the error was generated by IIS, a scripting language, or a component.
    • Column. Long integer of the column position within the .asp where the error occurred.
    • Description. String describing the error.
    • File. String with the name of the .asp file that generated the error.
    • Line. Long integer of the line within the .asp where the error occurred.
    • Number. Long integer for the error code returned by a COM component.
    • Source. String with the actual source text of the line that caused the error.

Basic Usage

<%
    Response.Write objASPError.Category
    If objASPError.ASPCode > "" Then Response.Write ", " & objASPError.ASPCode
    Response.Write " (0x" & Hex(objASPError.Number) & ")" & "<br>"

    Response.Write "<b>" & objASPError.Description & "</b><br>"

    If objASPError.ASPDescription > "" Then Response.Write objASPError.ASPDescription & "<br>"

    blnErrorWritten = False

    ' Only show the Source if it is available and the request is from the same machine as IIS
    If objASPError.Source > "" Then
        strServername = LCase(Request.ServerVariables("SERVER_NAME"))
        strServerIP = Request.ServerVariables("LOCAL_ADDR")
        strRemoteIP =  Request.ServerVariables("REMOTE_ADDR")
        If (strServername = "localhost" Or strServerIP = strRemoteIP) And objASPError.File <> "?" Then
            Response.Write objASPError.File
            If objASPError.Line > 0 Then Response.Write ", line " & objASPError.Line
            If objASPError.Column > 0 Then Response.Write ", column " & objASPError.Column
            Response.Write "<br>"
            Response.Write "<font style=""COLOR:000000; FONT: 8pt/11pt courier new""><b>"
            Response.Write Server.HTMLEncode(objASPError.Source) & "<br>"
            If objASPError.Column > 0 Then Response.Write String((objASPError.Column - 1), "-") & "^<br>"
            Response.Write "</b></font>"
            blnErrorWritten = True
        End If
    End If

    If Not blnErrorWritten And objASPError.File <> "?" Then
        Response.Write "<b>" & objASPError.File
        If objASPError.Line > 0 Then Response.Write ", line " & objASPError.Line
        If objASPError.Column > 0 Then Response.Write ", column " & objASPError.Column
        Response.Write "</b><br>"
    End If
%>


GeorgeHernandez.comSome rights reserved