2025-04-27 07:49:33 -04:00

158 lines
6.8 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=Windows-1252">
<TITLE>ASPError Object</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
TempString = navigator.appVersion
if (navigator.appName == "Microsoft Internet Explorer"){
// Check to see if browser is Microsoft
if (TempString.indexOf ("4.") >= 0){
// Check to see if it is IE 4
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/coua.css">');
}
else {
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/cocss.css">');
}
}
else if (navigator.appName == "Netscape") {
// Check to see if browser is Netscape
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/coua.css">');
}
else
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/cocss.css">');
//-->
</script>
<SCRIPT LANGUAGE="VBScript">
<!--
Sub Window_OnLoad()
Dim frmContents
On Error Resume Next
If Not Parent Is Nothing Then
Set frmContents = Parent.Contents
If Not frmContents Is Nothing Then
frmContents.Window.TOCSynch_Click
End If
End If
End Sub
//--></SCRIPT><META NAME="DESCRIPTION" CONTENT="Internet Information Services reference information">
<META HTTP-EQUIV="PICS-Label" CONTENT='(PICS-1.1 "<http://www.rsac.org/ratingsv01.html>" l comment "RSACi North America Server" by "inet@microsoft.com <mailto:inet@microsoft.com>" r (n 0 s 0 v 0 l 0))'>
<META NAME="MS.LOCALE" CONTENT="EN-US">
<META NAME="MS-IT-LOC" Content="Internet Information Services">
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H2><A NAME="_asperror_object"></A><SUP></SUP>ASPError Object</H2>
<P>You can use the <B>ASPError</B> object to obtain information about an error condition that has occurred in script in an ASP page. The <B>ASPError</B> object is returned by the <B>Server.GetLastError</B> method. The <B>ASPError</B> object exposes read-only properties.</P>
<H6>Syntax</H6>
<P><B>ASPError.property</B></P>
<H6>Properties</H6>
<TABLE border=0 cellpadding=5 cols=2 frame=box rules=all>
<TR VALIGN="top">
<TD width=50%><A HREF="/iishelp/iis/htm/asp/vbob742t.htm"><B>ASPCode</B></A></TD>
<TD width=50%>Returns an error code generated by IIS</TD>
</TR>
<TR VALIGN="top">
<TD width=50%><A HREF="/iishelp/iis/htm/asp/vbob8kz6.htm"><B>Number</B></A></TD>
<TD width=50%>Returns the standard COM error code</TD>
</TR>
<TR VALIGN="top">
<TD width=50%><A HREF="/iishelp/iis/htm/asp/vbob7fs5.htm"><B>Source</B></A></TD>
<TD width=50%>Returns the actual source code, when available, of the line that caused the error</TD>
</TR>
<TR VALIGN="top">
<TD width=50%><A HREF="/iishelp/iis/htm/asp/vbob33ll.htm"><B>Category</B></A></TD>
<TD width=50%>Indicates if the source of the error was internal to ASP, the scripting language, or an object</TD>
</TR>
<TR VALIGN="top">
<TD width=50%><A HREF="/iishelp/iis/htm/asp/vbob3wbp.htm"><B>File</B></A></TD>
<TD width=50%>Indicates the name of the .asp file that was being processed when the error occurred</TD>
</TR>
<TR VALIGN="top">
<TD width=50%><A HREF="/iishelp/iis/htm/asp/vbob7m1x.htm"><B>Line</B></A></TD>
<TD width=50%>Indicates the line within the .asp file that generated the error</TD>
</TR>
<TR VALIGN="top">
<TD width=50%><A HREF="/iishelp/iis/htm/asp/vbob2xf2.htm"><B>Column</B></A></TD>
<TD width=50%>Indicates the column position within the .asp file that generated the error</TD>
</TR>
<TR VALIGN="top">
<TD width=50%><A HREF="/iishelp/iis/htm/asp/vbob5pke.htm"><B>Description</B></A></TD>
<TD width=50%>Returns a short description of the error</TD>
</TR>
<TR VALIGN="top">
<TD width=50%><A HREF="/iishelp/iis/htm/asp/vbob79ke.htm"><B>ASPDescription</B></A></TD>
<TD width=50%>Returns a more detailed description of the error if it is an ASP-related error</TD>
</TR>
</TABLE><BR>
<H6>Remarks</H6>
<P>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 <B>ASPError</B> object which describes the error condition. For information on how to use the IIS snap-in to change the .asp file for processing 500;100 custom errors, see <A HREF="../core/iiprstop.htm">Enabling ASP Error Processing</A>.</P>
<H6>Example</H6>
<P>The following example, extracted from the file 500-100.asp, demonstrates writing the information exposed by the <B>ASPError</B> object.</P>
<PRE><CODE>&lt;%
Response.Write objASPError.Category
If objASPError.ASPCode &gt; "" Then Response.Write ", " &amp; objASPError.ASPCode
Response.Write " (0x" &amp; Hex(objASPError.Number) &amp; ")" &amp; "&lt;br&gt;"
Response.Write "&lt;b&gt;" &amp; objASPError.Description &amp; "&lt;/b&gt;&lt;br&gt;"
If objASPError.ASPDescription &gt; "" Then Response.Write objASPError.ASPDescription &amp; "&lt;br&gt;"
blnErrorWritten = False
' Only show the Source if it is available and the request is from the same machine as IIS
If objASPError.Source &gt; "" 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 &lt;&gt; "?" Then
Response.Write objASPError.File
If objASPError.Line &gt; 0 Then Response.Write ", line " &amp; objASPError.Line
If objASPError.Column &gt; 0 Then Response.Write ", column " &amp; objASPError.Column
Response.Write "&lt;br&gt;"
Response.Write "&lt;font style=""COLOR:000000; FONT: 8pt/11pt courier new""&gt;&lt;b&gt;"
Response.Write Server.HTMLEncode(objASPError.Source) &amp; "&lt;br&gt;"
If objASPError.Column &gt; 0 Then Response.Write String((objASPError.Column - 1), "-") &amp; "^&lt;br&gt;"
Response.Write "&lt;/b&gt;&lt;/font&gt;"
blnErrorWritten = True
End If
End If
If Not blnErrorWritten And objASPError.File &lt;&gt; "?" Then
Response.Write "&lt;b&gt;" &amp; objASPError.File
If objASPError.Line &gt; 0 Then Response.Write ", line " &amp; objASPError.Line
If objASPError.Column &gt; 0 Then Response.Write ", column " &amp; objASPError.Column
Response.Write "&lt;/b&gt;&lt;br&gt;"
End If
%&gt;
</CODE></PRE>
<H6>See Also</H6>
<P><A HREF="/iishelp/iis/htm/asp/vbob38aa.htm">Server.GetLastError</A></P>
<hr class="iis" size="1">
<p align="center"><em><a href="../../../common/colegal.htm">&copy; 1997-2001 Microsoft Corporation. All rights reserved.</a></em></p>
</BODY>
</HTML>