ASP GetLastError()Method (ASP 3.0)


Server 对象参考手册Complete Server Object Reference

The GetLastError method returns an ASPError object that describes the cause of the error.

By default, the website uses the file \iishelp\common\500-100.asp to handle ASP errors. You can use this file, or you can create your own file. If you want to change the ASP file that handles 500;100 custom errors, use the IIS snap-in.

Note:If an error occurs while IIS processes an ASP file or the application's Global.asa, a 500;100 custom error is generated.

Note:This method is only available before the ASP file sends any content to the browser.

Syntax

Server.GetLastError()

Examples

Example 1

In this example, the error occurs when IIS attempts to reference a file without using the file parameter in the include statement:

<!--#include f="header.inc" -->
<%
response.write("sometext")
%>

Example 2

In this example, an error occurs when compiling the script because the keyword "next" is missing:

<%
dim i
for i=1 to 10
  ........
nxt
%>

Example 3

In this example, an error occurs because the script attempts to divide a number by 0:

<%
dim i,tot,j
i=0
tot=0
j=0

for i=1 to 10
  tot=tot+1
next

tot=tot/j
%>


Server 对象参考手册Complete Server Object Reference Other Extensions