Platform SDK: IIS SDK |
The GetLastError method returns an ASPError Object describing the error condition that occurred. This method is available only before the .asp file has sent any content to the client.
Server.GetLastError()
If a 500;100 custom error has been defined for an ASP application, it may refer to an .asp file. In this case, when an error occurs during the running of an .asp file within the application, the server automatically transfers to this ASP page via the Server.Transfer method. All of the state information from the executing ASP application will be available to the .asp file that is handling the error. In addition, the ASPError Object will be available, so you can expose the properties of the error through the .asp file that you set up to handle the error.
The default Web site is configured to use the file \iishelp\common\500-100.asp. You can either use this file for processing ASP errors, or create your own. If you want to change the .asp file for processing the 500;100 custom errors you can use IIS Manager.
Note A 500;100 custom error will be generated if IIS encounters an error while processing either an .asp file or the application's Global.asa file.
The following three examples demonstrate different errors that generate a 500;100 custom error. The three types of errors are:
The following example demonstrates a preprocessing error, which IIS generates when it tries to include the file. This error will be generated because the #include statement is missing the file parameter for the #include statement.
<!--#include fil=inc.h -->
<%
response.write "hello"
%>
The following example demonstrates a script compiling error. The scripting engine does not compile this script because it is missing the keyword next in a For...Next loop.
<%
dim I
for i=1 to 1
nxt
%>
The following example demonstrates a run-time error that occurs because the script attempts to divide by 0.
<%
dim i,j
dim sum
sum=0
j=0
for i=1 to 10
sum=sum+1
next
sum=sum/j
%>
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 |