ASP應用進階 ASP Error對象的相關知識(2)_ASP教程
推薦:實例詳解ASP中斷開記錄集的使用方法我們在使用ASP 內置的ADO組件進行數據庫編程時,通常是在腳本的開頭打開一個連接,并在腳本的最后關閉它,但是就較大腳本而言,在多數情況下連接打開的時間要比它需要打開的時間長得多。因此為
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屬性中檢索)并在該頁面中顯示:
<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML3.2Final//EN"> <htmldir=ltr> <head> <style>a:link{font:9pt/11pt宋體;color:FF0000}a:visited{font:9pt/11pt宋體;color:#4e4e4e} </style> <METANAME="ROBOTS"CONTENT="NOINDEX"> <title>無法找到網頁</title> <METAHTTP-EQUIV="Content-Type"Content="text-html;charset=gb2312"> <METANAME="MS.LOCALE"CONTENT="ZH-CN"> </head> <script> functionHomepage(){ <!-- //inrealbits,urlsgetreturnedtoourscriptlikethis: //res://shdocvw.dll/http_404.htm#http://www.DocURL.com/bar.htm //FortestinguseDocURL="res://shdocvw.dll/http_404.htm#https://www.microsoft.com/bar.htm" DocURL=document.URL; //thisiswherethehttporhttpswillbe,asfoundbysearchingfor://butskippingtheres:// protocolIndex=DocURL.indexOf("://",4); //thisfindstheendingslashforthedomainserver serverIndex=DocURL.indexOf("/",protocolIndex 3); //forthehref,weneedavalidURLtothedomain.Wesearchforthe#symboltofindthebegining //ofthetrueURL,andadd1toskipit-thisistheBeginURLvalue.WeuseserverIndexastheendmarker. //urlresult=DocURL.substring(protocolIndex-4,serverIndex); BeginURL=DocURL.indexOf("#",1) 1; urlresult=DocURL.substring(BeginURL,serverIndex); //fordisplay,weneedtoskipafterhttp://,andgotothenextslash displayresult=DocURL.substring(protocolIndex 3,serverIndex); InsertElementAnchor(urlresult,displayresult); } functionHtmlEncode(text) { returntext.replace(/&/g,'&').replace(/'/g,'"').replace(/</g,'<').replace(/>/g,'>'); } functionTagAttrib(name,value) { return'' name '="' HtmlEncode(value) '"'; } functionPrintTag(tagName,needCloseTag,attrib,inner){ document.write('<' tagName attrib '>' HtmlEncode(inner)); if(needCloseTag)document.write('</' tagName '>'); } functionURI(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(/:/g,':').replace(/;/g,';'); } functionInsertElementAnchor(href,text) { PrintTag('A',true,TagAttrib('HREF',URI(href)),text); } //--> </script> <bodybgcolor="FFFFFF"> <tablewidth="410"cellpadding="3"cellspacing="5"> <tr> <tdalign="left"valign="middle"width="360"> <h1style="COLOR:000000;FONT:12pt/15pt宋體"><!--Problem-->無法找到網頁</h1> </td> </tr> <tr> <tdwidth="400"colspan="2"><fontstyle="COLOR:000000;FONT:9pt/11pt宋體">您正在搜索的網頁可能已經刪除、更名或暫時不可用。</font></td> </tr> <tr> <tdwidth="400"colspan="2"><fontstyle="COLOR:000000;FONT:9pt/11pt宋體"> <hrcolor="#C0C0C0"noshade> <p>請嘗試下列操作:</p> <ul> <li>如果您在“地址”欄中鍵入了網頁地址,請檢查其拼寫是否正確。<br> </li> <li>打開<script> <!-- if(!((window.navigator.userAgent.indexOf("MSIE")>0)&&(window.navigator.appVersion.charAt(0)=="2"))) { Homepage(); } //--> </script>主頁,尋找指向所需信息的鏈接。</li> <li>單擊<ahref="javascript:history.back(1)">后退</a>按鈕嘗試其他鏈接。</li> </ul> <h2style="font:9pt/11pt宋體;color:000000">HTTP404-無法找到文件<br>Internet信息服務<BR></h2> <hrcolor="#C0C0C0"noshade> <p>技術信息(支持個人)</p> <ul> <li>詳細信息:<br><ahref="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> </li> </ul> </font></td> </tr> </table> </body> </html> |
分享:請注意!常見的ASP腳本攻擊及防范技巧由于ASP的方便易用,越來越多的網站后臺程序都使用ASP腳本語言。但是, 由于ASP本身存在一些安全漏洞,稍不小心就會給黑客提供可乘之機。事實上,安全不僅是網管的事,編程人員也必須在某些安全
- 相關鏈接:
- 教程說明:
ASP教程-ASP應用進階 ASP Error對象的相關知識(2)。