ASP GetLastError() 方法 (ASP 3.0)
定義和用法
GetLastError 方法返回 ASPError 對象,描述發(fā)生錯誤的原因。
默認(rèn)地,網(wǎng)站會使用文件 \iishelp\common\500-100.asp 來處理 ASP 錯誤。您即可以使用此文件,也可以創(chuàng)建自己的文件。如果您希望改變處理 500;100 custom errors 的 ASP 文件,請使用 IIS snap-in 。
注釋:如果在 IIS 處理 ASP 文件或應(yīng)用程序的 Global.asa 時碰到錯誤,就會生成500;100 custom error。
注釋:此方法僅在 ASP 文件發(fā)送任何內(nèi)容到瀏覽器之前可用。
語法
Server.GetLastError()
實例
例子 1
在本例中,在 IIS 試圖引用文件,而 include 語句沒有使用 file 參數(shù)時,錯誤就會發(fā)生:
<!--#include f="header.inc" --> <% response.write("sometext") %>
例子 2
在本例中,當(dāng)編譯腳本時,由于關(guān)鍵詞 "next" 被遺漏,就會發(fā)生錯誤:
<% dim i for i=1 to 10 ........ nxt %>
例子 3
在本例中,由于腳本試圖用 0 來除一個數(shù),就會發(fā)生錯誤:
<% dim i,tot,j i=0 tot=0 j=0 for i=1 to 10 tot=tot+1 next tot=tot/j %>