国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > ASP > 正文

ASP的Error對象知識簡析

2024-05-04 11:10:04
字體:
來源:轉載
供稿:網友

這篇文章主要介紹了ASP的Error對象,需要的朋友可以參考下

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

 

 
  1. If Err Then 
  2. err.Clear 
  3. Response.Write "出現了錯誤!" 
  4. Response.End 
  5. End If 

為了得到更加詳細的錯誤說明,我們就試試asperror對象吧,它是asp3.0的新對象,它可以通過server對象的getlasterror方法得到,asperror提供了關于asp中發生最后一個錯誤的詳細信息,與VBScript的Err對象不同,不能為查看是否出現了錯誤而隨時調用該方法,只能在一個ASP定制的錯誤網頁中使用。如果像對Err對象進行操作那樣,通過關閉缺省的錯誤處理(用On Error Resume Next語句)來使用,則GetLastError方法不能訪問錯誤的詳細數據。

ASPError對象的屬性:

ASPError對象提供了九個屬性說明所出現的錯誤的性質和錯誤源,并返回引發錯誤的實際代碼,其屬性及說明如下:

ASPCode:整型。由ASP/IIS產生的錯誤號,例如0x800A009

ASPDescription: 字符串型。如果這個錯誤是與ASP相關的錯誤,這個屬性是錯誤的詳細說明.例如: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內部腳本語言、或一個對象.

Column:整型。產生錯誤的文件中的字符位置

Description:字符串型。錯誤的簡短說明

File:字符串型。錯誤出現時正在處理的文件的名稱

Line:整型。產生錯誤的文件中的行號

Number:整型。一個標準的COM錯誤代碼

Source:字符串型。引發錯誤的行的實際代碼

ok,這就是9個屬性,使用asperror對象的語法是:

asperror.property

就是這樣:

ASPError.ASPCode()

ASPError.ASPDescription()

ASPError.Category()

ASPError.Column()

ASPError.Description()

ASPError.File()

ASPError.Line()

ASPError.Number()

ASPError.Source()

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

 

 
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"
  2. <html dir=ltr> 
  3. <head> 
  4. <style> a:link {font:9pt/11pt 宋體; color:FF0000} a:visited {font:9pt/11pt 宋體; color:#4e4e4e} 
  5. </style> 
  6. <META NAME="ROBOTS" CONTENT="NOINDEX"
  7. <title>無法找到網頁</title> 
  8. <META HTTP-EQUIV="Content-Type" Content="text-html; charset=gb2312"
  9. <META NAME="MS.LOCALE" CONTENT="ZH-CN"
  10. </head> 
  11. <script> 
  12. function Homepage(){ 
  13. <!-- 
  14. // in real bits, urls get returned to our script like this: 
  15. // res://shdocvw.dll/http_404.htm#http://www.DocURL.com/bar.htm 
  16. //For testing use DocURL = "res://shdocvw.dll/http_404.htm#https://www.microsoft.com/bar.htm" 
  17. DocURL = document.URL; 
  18. //this is where the http or https will be, as found by searching for :// but skipping the res:// 
  19. protocolIndex=DocURL.indexOf("://",4); 
  20. //this finds the ending slash for the domain server 
  21. serverIndex=DocURL.indexOf("/",protocolIndex + 3); 
  22. //for the href, we need a valid URL to the domain. We search for the # symbol to find the begining 
  23. //of the true URL, and add 1 to skip it - this is the BeginURL value. We use serverIndex as the end marker. 
  24. //urlresult=DocURL.substring(protocolIndex - 4,serverIndex); 
  25. BeginURL=DocURL.indexOf("#",1) + 1; 
  26. urlresult=DocURL.substring(BeginURL,serverIndex); 
  27. //for display, we need to skip after http://, and go to the next slash 
  28. displayresult=DocURL.substring(protocolIndex + 3 ,serverIndex); 
  29. InsertElementAnchor(urlresult, displayresult); 
  30. function HtmlEncode(text) 
  31. return text.replace(/&/g, '&').replace(/'/g, '"').replace(/</g, '<').replace(/>/g, '>'); 
  32. function TagAttrib(name, value) 
  33. return ' '+name+'="'+HtmlEncode(value)+'"'
  34. function PrintTag(tagName, needCloseTag, attrib, inner){ 
  35. document.write( '<' + tagName + attrib + '>' + HtmlEncode(inner) ); 
  36. if (needCloseTag) document.write( '</' + tagName +'>' ); 
  37. function URI(href) 
  38. IEVer = window.navigator.appVersion; 
  39. IEVer = IEVer.substr( IEVer.indexOf('MSIE') + 5, 3 ); 
  40. return (IEVer.charAt(1)=='.' && IEVer >= '5.5') ? 
  41. encodeURI(href) : 
  42. escape(href).replace(/%3A/g, ':').replace(/%3B/g, ';'); 
  43. function InsertElementAnchor(href, text) 
  44. PrintTag('A'true, TagAttrib('HREF', URI(href)), text); 
  45. //--> 
  46. </script> 
  47. <body bgcolor="FFFFFF"
  48. <table width="410" cellpadding="3" cellspacing="5"
  49. <tr> 
  50. <td align="left" valign="middle" width="360"
  51. <h1 style="COLOR:000000; FONT: 12pt/15pt 宋體"><!--Problem-->無法找到網頁</h1> 
  52. </td> 
  53. </tr> 
  54. <tr> 
  55. <td width="400" colspan="2"> <font style="COLOR:000000; FONT: 9pt/11pt 宋體">您正在搜索的網頁可能已經刪除、更名或暫時不可用。</font></td> 
  56. </tr> 
  57. <tr> 
  58. <td width="400" colspan="2"> <font style="COLOR:000000; FONT: 9pt/11pt 宋體"
  59. <hr color="#C0C0C0" noshade> 
  60. <p>請嘗試下列操作:</p> 
  61. <ul> 
  62. <li>如果您在“地址”欄中鍵入了網頁地址,請檢查其拼寫是否正確。<br> 
  63. </li> 
  64. <li>打開 <script> 
  65. <!-- 
  66. if (!((window.navigator.userAgent.indexOf("MSIE") > 0) && (window.navigator.appVersion.charAt(0) == "2"))) 
  67. Homepage(); 
  68. //--> 
  69. </script> 主頁,尋找指向所需信息的鏈接。</li> 
  70. <li>單擊<a href="javascript:history.back(1)">后退</a>按鈕嘗試其他鏈接。</li> 
  71. </ul> 
  72. <h2 style="font:9pt/11pt 宋體; color:000000">HTTP 404 - 無法找到文件<br> Internet 信息服務<BR></h2> 
  73. <hr color="#C0C0C0" noshade> 
  74. <p>技術信息(支持個人)</p> 
  75. <ul> 
  76. <li>詳細信息:<br><a href="http://www.microsoft.com/ContentRedirect.asp?prd=iis&sbp=&pver=5.0&pid=&ID=404&cat=web&os=&over=&hrd=&Opt1=&Opt2=&Opt3=" target="_blank">Microsoft 支持</a> 
  77. </li> 
  78. </ul> 
  79. </font></td> 
  80. </tr> 
  81. </table> 
  82. </body> 
  83. </html> 

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

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 黔西| 柳河县| 新宾| 富川| 灌阳县| 大悟县| 中牟县| 张家港市| 南充市| 昭觉县| 林口县| 武鸣县| 车险| 萝北县| 崇仁县| 桂东县| 临泉县| 余干县| 黄骅市| 福泉市| 内黄县| 永年县| 阿坝县| 望奎县| 金平| 罗田县| 辛集市| 盱眙县| 南靖县| 革吉县| 清徐县| 司法| 且末县| 霸州市| 太保市| 南开区| 茂名市| 平陆县| 五大连池市| 桂阳县| 南乐县|