ASP GetLastError() Method (ASP 3.0)

Server Object Reference Manual

Definition and Usage

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 either use this file or create your own file. If you want to change the ASP file that handles 500;100 custom errors, please use the IIS snap-in.

Note:If an error occurs when IIS is processing an ASP file or the Global.asa application, 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()

Instance

Example 1

In this example, an error occurs when IIS tries to reference a file and the include statement does not use the file parameter:

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

Example 2

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

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

Example 3

In this example, an error will occur because the script tries 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 Object Reference Manual