国产成人精品18p,天天干成人网,无码专区狠狠躁天天躁,美女脱精光隐私扒开免费观看

ASP的Error對象知識簡(jiǎn)析

發(fā)布時(shí)間:2021-08-17 12:10 來(lái)源: 閱讀:0 作者: 欄目: ASP 歡迎投稿:712375056

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

If Err Then
err.Clear
Response.Write "出現了錯誤!"
Response.End
End If

為了得到更加詳細的錯誤說(shuō)明,我們就試試asperror對象吧,它是asp3.0的新對象,它可以通過(guò)server對象的getlasterror方法得到,asperror提供了關(guān)于asp中發(fā)生最后一個(gè)錯誤的詳細信息,與VBScript的Err對象不同,不能為查看是否出現了錯誤而隨時(shí)調用該方法,只能在一個(gè)ASP定制的錯誤網(wǎng)頁(yè)中使用。如果像對Err對象進(jìn)行操作那樣,通過(guò)關(guān)閉缺省的錯誤處理(用On Error Resume Next語(yǔ)句)來(lái)使用,則GetLastError方法不能訪(fǎng)問(wèn)錯誤的詳細數據。
ASPError對象的屬性:
ASPError對象提供了九個(gè)屬性說(shuō)明所出現的錯誤的性質(zhì)和錯誤源,并返回引發(fā)錯誤的實(shí)際代碼,其屬性及說(shuō)明如下:
ASPCode:整型。由ASP/IIS產(chǎn)生的錯誤號,例如0x800A009
ASPDescription: 字符串型。如果這個(gè)錯誤是與ASP相關(guān)的錯誤,這個(gè)屬性是錯誤的詳細說(shuō)明.例如: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:字符串型。錯誤來(lái)源,即ASP內部腳本語(yǔ)言、或一個(gè)對象.
Column:整型。產(chǎn)生錯誤的文件中的字符位置
Description:字符串型。錯誤的簡(jiǎn)短說(shuō)明
File:字符串型。錯誤出現時(shí)正在處理的文件的名稱(chēng)
Line:整型。產(chǎn)生錯誤的文件中的行號
Number:整型。一個(gè)標準的COM錯誤代碼
Source:字符串型。引發(fā)錯誤的行的實(shí)際代碼
ok,這就是9個(gè)屬性,使用asperror對象的語(yǔ)法是:
asperror.property
就是這樣:

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

<!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ú)法找到網(wǎng)頁(yè)</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ú)法找到網(wǎng)頁(yè)</h1>
 </td>
 </tr>
 <tr>
<td width="400" colspan="2"> <font style="COLOR:000000; FONT: 9pt/11pt 宋體">您正在搜索的網(wǎng)頁(yè)可能已經(jīng)刪除、更名或暫時(shí)不可用。</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)頁(yè)地址,請檢查其拼寫(xiě)是否正確。<br>
  </li>
<li>打開(kāi) <script>
  <!--
  if (!((window.navigator.userAgent.indexOf("MSIE") > 0) && (window.navigator.appVersion.charAt(0) == "2")))
  {
   Homepage();
  }
  //-->
  </script> 主頁(yè),尋找指向所需信息的鏈接。</li>
<li>單擊<a href="javascript:history.back(1)">后退</a>按鈕嘗試其他鏈接。</li>
 </ul>
<h2 style="font:9pt/11pt 宋體; color:000000">HTTP 404 - 無(wú)法找到文件<br> Internet 信息服務(wù)<BR></h2>
 <hr color="#C0C0C0" noshade>
 <p>技術(shù)信息(支持個(gè)人)</p>
<ul>
<li>詳細信息:<br><a  target="_blank">Microsoft 支持</a>
</li>
</ul>
 </font></td>
 </tr>
</table>
</body>
</html>

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

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng )、來(lái)自本網(wǎng)站內容采集于網(wǎng)絡(luò )互聯(lián)網(wǎng)轉載等其它媒體和分享為主,內容觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如侵犯了原作者的版權,請告知一經(jīng)查實(shí),將立刻刪除涉嫌侵權內容,聯(lián)系我們QQ:712375056,同時(shí)歡迎投稿傳遞力量。

丰满熟妇乱又伦精品| 亚洲综合性av私人影院| 中国字幕免费观看| 成在人线AV无码免费高潮喷水| 国产精鲁鲁| 蜜桃臀AV高潮无码|