Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

ASP GetLastError Method

ASP GetLastError() Method (ASP 3.0)


Server Object Reference Complete Server Object Reference Manual


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

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

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

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

Syntax

Server.GetLastError()

Example

Example 1

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

<%

response.write("sometext")

%>

Example 2

In this example, an error occurs when the script is compiled 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 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 Complete Server Object Reference Manual