欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

ASP的Error對象知識簡析

 更新時間:2015年09月14日 12:00:50   投稿:lijiao  
這篇文章主要介紹了ASP的Error對象,需要的朋友可以參考下

在VBScript中,有一個On Error Resume Next語句,它使腳本解釋器忽略運行期錯誤并繼續(xù)腳本代碼的執(zhí)行。接著該腳本可以檢查Err.Number屬性的值,判別是否出現(xiàn)了錯誤。如果出現(xiàn)錯誤,返回一個非零值。在ASP3.0中,也可以使用OnErrorGoto0“轉(zhuǎn)回到”缺省的錯誤處理。在ASP2.0中實際也進(jìn)行這種處理,但是沒有相應(yīng)文檔說明,這在很多asp數(shù)據(jù)相關(guān)處理文件中司空見慣,加上On Error Resume Next,關(guān)閉缺省的錯誤處理,然后用err抓住,

If Err Then
err.Clear
Response.Write "出現(xiàn)了錯誤!"
Response.End
End If

為了得到更加詳細(xì)的錯誤說明,我們就試試asperror對象吧,它是asp3.0的新對象,它可以通過server對象的getlasterror方法得到,asperror提供了關(guān)于asp中發(fā)生最后一個錯誤的詳細(xì)信息,與VBScript的Err對象不同,不能為查看是否出現(xiàn)了錯誤而隨時調(diào)用該方法,只能在一個ASP定制的錯誤網(wǎng)頁中使用。如果像對Err對象進(jìn)行操作那樣,通過關(guān)閉缺省的錯誤處理(用On Error Resume Next語句)來使用,則GetLastError方法不能訪問錯誤的詳細(xì)數(shù)據(jù)。
ASPError對象的屬性:
ASPError對象提供了九個屬性說明所出現(xiàn)的錯誤的性質(zhì)和錯誤源,并返回引發(fā)錯誤的實際代碼,其屬性及說明如下:
ASPCode:整型。由ASP/IIS產(chǎn)生的錯誤號,例如0x800A009
ASPDescription: 字符串型。如果這個錯誤是與ASP相關(guān)的錯誤,這個屬性是錯誤的詳細(xì)說明.例如:AllHTTP:HTTP_ACCEPT:*/*HTTP_ACCEPT_LANGUAGE:zh-cnHTTP_CONNECTION:Keep-AliveHTTP_HOST:sHTTP_USER_AGENT:Mozilla/4.0(compatible;MSIE6.0;WindowsNT5.0;(R11.5))...還有cookie等報告.
Category:字符串型。錯誤來源,即ASP內(nèi)部腳本語言、或一個對象.
Column:整型。產(chǎn)生錯誤的文件中的字符位置
Description:字符串型。錯誤的簡短說明
File:字符串型。錯誤出現(xiàn)時正在處理的文件的名稱
Line:整型。產(chǎn)生錯誤的文件中的行號
Number:整型。一個標(biāo)準(zhǔn)的COM錯誤代碼
Source:字符串型。引發(fā)錯誤的行的實際代碼
ok,這就是9個屬性,使用asperror對象的語法是:
asperror.property
就是這樣:

ASPError.ASPCode()
ASPError.ASPDescription()
ASPError.Category()
ASPError.Column()
ASPError.Description()
ASPError.File()
ASPError.Line()
ASPError.Number()
ASPError.Source()
在iis支持的所有目錄下面(或:在編輯了錯誤映射屬性的目錄內(nèi))的任一頁面上出現(xiàn)一個與ASP相關(guān)的錯誤時,都將載入定制錯誤頁面。實際上,現(xiàn)在已經(jīng)設(shè)置了一個正常的腳本錯誤陷阱,因為在這個目錄內(nèi)的任何一個網(wǎng)頁上的ASP運行期錯誤都將觸發(fā)定制錯誤頁面,錯誤網(wǎng)頁作為IIS的缺省安裝部分,可根據(jù)個人情況定制.例如,當(dāng)我們在一個目錄下面輸入不存在的網(wǎng)頁時,出現(xiàn)404錯誤,當(dāng)一個404錯誤出現(xiàn)時,使用的頁面是404b.htm,這個文件包含一個客戶端腳本代碼部分,它獲得當(dāng)前文檔的URL(從document對象的url屬性中檢索)并在該頁面中顯示:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html dir=ltr>
<head>
<style> a:link   {font:9pt/11pt 宋體; color:FF0000} a:visited  {font:9pt/11pt 宋體; color:#4e4e4e}
</style>
<META NAME="ROBOTS" CONTENT="NOINDEX">
<title>無法找到網(wǎng)頁</title>
<META HTTP-EQUIV="Content-Type" Content="text-html; charset=gb2312">
<META NAME="MS.LOCALE" CONTENT="ZH-CN">
</head>
<script>
function Homepage(){
<!--
// in real bits, urls get returned to our script like this:
// res://shdocvw.dll/http_404.htm#http://www.DocURL.com/bar.htm
 //For testing use DocURL = "res://shdocvw.dll/http_404.htm#https://www.microsoft.com/bar.htm"
 DocURL = document.URL;
 //this is where the http or https will be, as found by searching for :// but skipping the res://
 protocolIndex=DocURL.indexOf("://",4);
 //this finds the ending slash for the domain server
 serverIndex=DocURL.indexOf("/",protocolIndex + 3);
  //for the href, we need a valid URL to the domain. We search for the # symbol to find the begining
 //of the true URL, and add 1 to skip it - this is the BeginURL value. We use serverIndex as the end marker.
 //urlresult=DocURL.substring(protocolIndex - 4,serverIndex);
 BeginURL=DocURL.indexOf("#",1) + 1;
 urlresult=DocURL.substring(BeginURL,serverIndex);
 //for display, we need to skip after http://, and go to the next slash
 displayresult=DocURL.substring(protocolIndex + 3 ,serverIndex);
 InsertElementAnchor(urlresult, displayresult);
}
function HtmlEncode(text)
{
 return text.replace(/&/g, '&amp').replace(/'/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
}
function TagAttrib(name, value)
{
 return ' '+name+'="'+HtmlEncode(value)+'"';
}
function PrintTag(tagName, needCloseTag, attrib, inner){
 document.write( '<' + tagName + attrib + '>' + HtmlEncode(inner) );
 if (needCloseTag) document.write( '</' + tagName +'>' );
}
function URI(href)
{
 IEVer = window.navigator.appVersion;
 IEVer = IEVer.substr( IEVer.indexOf('MSIE') + 5, 3 );
 return (IEVer.charAt(1)=='.' && IEVer >= '5.5') ?
  encodeURI(href) :
  escape(href).replace(/%3A/g, ':').replace(/%3B/g, ';');
}
function InsertElementAnchor(href, text)
{
 PrintTag('A', true, TagAttrib('HREF', URI(href)), text);
}
//-->
</script>
<body bgcolor="FFFFFF">
<table width="410" cellpadding="3" cellspacing="5">
 <tr>
 <td align="left" valign="middle" width="360">
 <h1 style="COLOR:000000; FONT: 12pt/15pt 宋體"><!--Problem-->無法找到網(wǎng)頁</h1>
 </td>
 </tr>
 <tr>
<td width="400" colspan="2"> <font style="COLOR:000000; FONT: 9pt/11pt 宋體">您正在搜索的網(wǎng)頁可能已經(jīng)刪除、更名或暫時不可用。</font></td>
 </tr>
 <tr>
 <td width="400" colspan="2"> <font style="COLOR:000000; FONT: 9pt/11pt 宋體">
 <hr color="#C0C0C0" noshade>
<p>請嘗試下列操作:</p>
 <ul>
<li>如果您在“地址”欄中鍵入了網(wǎng)頁地址,請檢查其拼寫是否正確。<br>
  </li>
<li>打開 <script>
  <!--
  if (!((window.navigator.userAgent.indexOf("MSIE") > 0) && (window.navigator.appVersion.charAt(0) == "2")))
  {
   Homepage();
  }
  //-->
  </script> 主頁,尋找指向所需信息的鏈接。</li>
<li>單擊<a href="javascript:history.back(1)">后退</a>按鈕嘗試其他鏈接。</li>
 </ul>
<h2 style="font:9pt/11pt 宋體; color:000000">HTTP 404 - 無法找到文件<br> Internet 信息服務(wù)<BR></h2>
 <hr color="#C0C0C0" noshade>
 <p>技術(shù)信息(支持個人)</p>
<ul>
<li>詳細(xì)信息:<br><a  target="_blank">Microsoft 支持</a>
</li>
</ul>
 </font></td>
 </tr>
</table>
</body>
</html>

以上就是對ASP error對象的全部簡析,希望對大家的學(xué)習(xí)有所幫助。

相關(guān)文章

最新評論