Platform SDK: IIS SDK |
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.
ASPError.property
ASPError.ASPCode | Returns an error code generated by IIS. |
ASPError.Number | Returns the standard COM error code. |
ASPError.Source | Returns the actual source code, when available, of the line that caused the error. |
ASPError.Category | Indicates if the source of the error was internal to ASP, the scripting language, or an object. |
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.Column | Indicates the column position within the .asp file that generated the error. |
ASPError.Description | Returns a short description of the error. |
ASPError.ASPDescription | Returns a more detailed description of the error, if it is an ASP-related 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, extracted from the file 500-100.asp, demonstrates writing the information exposed by the ASPError object.
<%
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 =index.html 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="index.html"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
%>
Platforms: Windows 2000 with IIS 5.0 installed,
Windows XP with IIS 5.1 installed,
Windows Server 2003 family with IIS 6.0 installed
What did you think of this topic? |
Order a Platform SDK CD |
file: /Techref/language/asp/obj/ref_vbom_aseo.htm, 6KB, , updated: 2003/5/15 13:13, local time: 2024/11/5 23:27,
34.204.176.71:LOG IN ©2024 PLEASE DON'T RIP! THIS SITE CLOSES OCT 28, 2024 SO LONG AND THANKS FOR ALL THE FISH!
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://techref.massmind.org/techref/language/asp/obj/ref_vbom_aseo.htm"> ASPError Object</A> |
Did you find what you needed? |
Welcome to massmind.org! |
Welcome to techref.massmind.org! |
.