この記事では、主にそれを必要とするASPのエラーオブジェクトを紹介します
vbscriptには、スクリプトインタープリターがランタイムエラーを無視し、スクリプトコードの実行を継続するために、on error resumeの次のステートメントがあります。次に、スクリプトはERR.Numberプロパティの値を確認して、エラーが発生したかどうかを判断できます。エラーが発生した場合、ゼロ以外の値が返されます。 ASP3.0では、onerrorgoto0を使用してデフォルトのエラー処理に戻ることもできます。この種の処理は実際にASP2.0で実行されますが、対応するドキュメントの説明はありません。これは、ASPデータ関連の多くの処理ファイルで一般的です。
- iferrthen
- err.clear
- Response.writeにエラーがあります!
- Response.End
- endif
より詳細なエラーの説明を取得するために、ASPERRORの新しいオブジェクトをASPのGetLasterRorメソッドを提供します。また、VBScriptのERRオブジェクトは、エラーが発生するかどうかを確認することができません。 ERRオブジェクトのように、デフォルトのエラー処理がオフになっている場合(ON ERROR Resume Nextステートメントを使用)、GetLasterRorメソッドはエラーの詳細データにアクセスできません。
Asperrorオブジェクトのプロパティ:
Asperrorオブジェクトは、発生したエラーの性質とソースを示す9つの属性を提供し、エラーと説明を引き起こす実際のコードを返します。
ASPCODE:整数。 0x800A009など、ASP/IISによって生成されたエラー番号
AspDescription:文字列タイプ。このエラーがASP関連のエラーである場合、このプロパティはエラーの詳細な説明です。 0; windowsnt5 .0;(r11.5)).. Cookieなどのレポートもあります。
カテゴリ:文字列タイプ。エラーのソースは、ASP内部スクリプト言語、またはオブジェクトのソースです。
列:整数。エラーを生成したファイル内の文字位置
説明:文字列タイプ。エラーの簡単な説明
ファイル:文字列タイプ。エラーが発生したときに処理されるファイルの名前
ライン:整数。エラーを生成したファイル内の行番号
番号:整数。標準のCOMエラーコード
出典:文字列タイプ。エラーを上げた行の実際のコード
OK、これらは9つのプロパティです。
asperror.property
それでおしまい:
asperror.aspcode()
asperror.aspdescription()
asperror.category()
asperror.column()
asperror.description()
asperror.file()
asperror.line()
asperror.number()
asperror.source()
IISでサポートされているすべてのディレクトリ(またはエラーマッピングプロパティが編集されているディレクトリ)でASP関連のエラーが発生すると、カスタムエラーページがロードされます。実際、このディレクトリの任意のWebページのASPランタイムエラーがカスタマイズされたエラーページがIISのデフォルトのインストール部分であるため、通常のスクリプトエラートラップが設定されています。たとえば、ディレクトリに存在しないWebページを入力すると、404エラーが発生した場合、このファイルにはクライアントスクリプトコードが含まれています。現在のドキュメントドキュメントオブジェクトのURL(ドキュメントオブジェクトのURLプロパティから取得)とページに表示されます。
- <!doctypehtmlpublic - // w3c // dtdhtml3.2final // en>
- <htmldir = ltr>
- <head>
- <style> a:link {font:9pt/11pt安安; color:ff0000} a:訪問{font:9pt/11pt安安安安; color:#4e4e4e}
- </style>
- <Metaname = robotscontent = noindex>
- <Title> Webページを見つけることができません</title>
- <metahttp-equiv = content-typecontent = text-html; charset = gb2312>
- <Metaname = Ms.LocaleContent = en-Cn>
- </head>
- <スクリプト>
- 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:// butskipptheres://
- protocolindex = docurl.indexof(://、4);
- // thisfindstheEndingslashforthedomainserver
- serverIndex = docurl.indexof(/、protocolindex+3);
- //forthehref、weneedavalidurltothedomain.wesearchforthe #symboltofindthebegining
- ///ofthetrueurl、andadd1toskipit-thisistthebeginurlvalue.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(テキスト)
- {
- returnText.Replace(/&/g、 '&')。置換(/'/g、' ')。置き換え(/</g、' <')。
- }
- functiontagattrib(名前、値)
- {
- return ''+name+'='+htmlencode(value)+'';
- }
- functionprinttag(tagname、needclosetag、attrib、inner){
- document.write( '<'+tagname+attrib+'>'+htmlencode(inner));
- if(needclosetag)document.write( '</'+tagname+'>');
- }
- functioni(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、 ':')。置換(/%3b/g、 ';');
- }
- functionInsertelementanchanor(href、テキスト)
- {
- printtag( 'a'、true、tagattrib( 'href'、uri(href))、text);
- }
- //->
- </script>
- <bodybgcolor = ffffff>
- <TableWidth = 410CellPadding = 3CellPacing = 5>
- <tr>
- <tdalign = leftalign = middlewidth = 360>
- <h1style = color:000000; font:12pt/15pt安安> <! - 問題 - > Webページは見つかりません</h1>
- </td>
- </tr>
- <tr>
- <tdwidth = 400Colspan = 2> <fontstyle = color:000000; font:9pt/11pt>検索しているWebページは、削除、変更、または一時的に利用できない可能性があります。 </font> </td>
- </tr>
- <tr>
- <tdwidth = 400colspan = 2> <fontstyle = color:000000; font:9pt/11pt安安>
- <hrcolor =#c0c0c0noshade>
- <p>以下を試してください:</p>
- <ul>
- <li>アドレスバーでWebアドレスを入力した場合は、正しく綴られていることを確認してください。 <br>
- </li>
- <li> open <script>
- <! -
- if(!((window.navigator.useragent.indexof(msie)> 0)&&(window.navigator.appversion.charat(0)== 2)))))
- {
- HomePage();
- }
- //->
- </script>ホームページ、必要な情報へのリンクを見つけます。 </li>
- <li> <ahref = javascript:history.back(1)> back </a>ボタンをクリックして、他のリンクを試してください。 </li>
- </ul>
- <h2style = font:9pt/11pt安安; color:000000> http404-fileは見つかりません<br>インターネット情報サービス<br> </h2>
- <hrcolor =#c0c0c0noshade>
- <p>技術情報(個人のサポート)</p>
- <ul>
- <li>詳細:<br> <ahref = http://www.microsoft.com/contentredirect.asp?prd = iis&sbp =&pver = 5.0&pid =&id = 404&cat = web&os =&os =&hrd =&hrd =&opt1 =&opt2 =&opt3 =ターゲット= _blank> Microsoftサポート</a>
- </li>
- </ul>
- </font> </td>
- </tr>
- </table>
- </body>
- </html>
上記は、ASPエラーオブジェクトの簡単な分析であり、すべての人の学習に役立つことを願っています。