最近經常有人問在win2000和IIS5中不顯示asp錯誤的詳細信息,而只顯示錯誤號,如"錯誤ID800xxxxx",這使得程序調試很不方便,有些人采取在IIS中設置500-100錯誤指向默認,這樣做也不會出現詳細的錯誤信息。實際上這可能是微軟出于安全考慮而在500-100.asp中沒有顯示詳細出錯信息。其實,你只要把500-100.asp稍加修改就可以了。下面是我修改的這個文件的內容。你只要把他copy下來存為500-100.asp然后覆蓋原來的這個文件就可以了。注意文件中兩行橫線之間就是我修改的部分。
500-100.asp:
<%@ language="VBScript" %> <% Option Explicit
Const lngMaxFormBytes = 200
Dim objASPError, blnErrorWritten, strServername, strServerIP, strRemoteIP Dim strMethod, lngPos, datNow, strQueryString, strURL
If Response.Buffer Then Response.Clear Response.Status = "500 Internal Server Error" Response.ContentType = "text/html" Response.Expires = 0 End If
Set objASPError = Server.GetLastError %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html dir=ltr>
<head> <style> a:link{font:9pt 宋體; color:FF0000} a:visited{font:9pt 宋體; color:#4e4e4e} </style>
<META NAME="ROBOTS" CONTENT="NOINDEX">
<title>本頁無法顯示</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); document.write('<A HREF="' + urlresult + '">' + displayresult + "</a>"); } //--> </script>
<body bgcolor="FFFFFF">
<table width="410" cellpadding="3" cellspacing="5">
<tr> <td align="left" valign="middle" width="360"> <h1 style="COLOR:000000; FONT: 9pt 宋體"><!--Problem-->本頁無法顯示</h1> </td> </tr>
<tr> <td width="400" colspan="2"> <font style="COLOR:000000; FONT: 9pt 宋體">試圖訪問的網頁出現問題,無法顯示。</font></td> </tr>
<tr> <td width="400" colspan="2"> <font style="COLOR:000000; FONT: 9pt 宋體">
<hr color="#C0C0C0" noshade>
<p>請嘗試以下方法:</p>
<ul> <li id="instructionsText1">單擊 <a href="javascript:location.reload()"> 刷新</a>按鈕或者梢候再試。<br> </li>
<li>打開
<script> <!-- if (!((window.navigator.userAgent.indexOf("MSIE") > 0) && (window.navigator.appVersion.charAt(0) == "2"))) { Homepage(); } //--> </script>
主頁,然后查找與所需信息相關的鏈接。 </li> </ul>
<h2 style="FONT: 9pt 宋體; color:000000">HTTP 500.100 - 內部服務器錯誤 - ASP 錯誤<br> Internet 信息服務</h2>
<hr color="#C0C0C0" noshade>
<p>技術信息(適用于支持人員)</p>
<ul> <li>錯誤類型:<br> <% Dim bakCodepage bakCodepage = Session.Codepage Session.Codepage = 936 Response.Write Server.HTMLEncode(objASPError.Category) If objASPError.ASPCode > "" Then Response.Write Server.HTMLEncode(", " & objASPError.ASPCode) Response.Write Server.HTMLEncode(" (0x" & Hex(objASPError.Number) & ")" ) & "<br>"
If objASPError.ASPDescription > "" Then Response.Write Server.HTMLEncode(objASPError.ASPDescription) & "<br>"
blnErrorWritten = False
' Only show the Source if it is available and the request is from the same machine as IIS If objASPError.Source > "" Then strServername = LCase(Request.ServerVariables("SERVER_NAME")) strServerIP = Request.ServerVariables("LOCAL_ADDR") strRemoteIP =Request.ServerVariables("REMOTE_ADDR") If (strServername = "localhost" Or strServerIP = strRemoteIP) And objASPError.File <> "?" Then Response.Write Server.HTMLEncode(objASPError.File) If objASPError.Line > 0 Then Response.Write ", 第 " & objASPError.Line & " 行" If objASPError.Column > 0 Then Response.Write ", 第 " & objASPError.Column & " 列" Response.Write "<br>" Response.Write "<font style=""COLOR:000000; FONT: 9pt 宋體""><b>" Response.Write Server.HTMLEncode(objASPError.Source) & "<br>" If objASPError.Column > 0 Then Response.Write String((objASPError.Column - 1), "-") & "^<br>" Response.Write "</b></font>" blnErrorWritten = True End If End If
If Not blnErrorWritten And objASPError.File <> "?" Then Response.Write "<b>" Response.Write Server.HTMLEncode(objASPError.File) If objASPError.Line > 0 Then Response.Write Server.HTMLEncode(", 第 " & objASPError.Line & " 行") If objASPError.Column > 0 Then Response.Write ", 第 " & objASPError.Column & " 列" '------------------------------------------------------------------- ' added by Bigeagle ' date:2000/5/10
dim l_strAspDescription l_strAspDescription = "錯誤原因:" + objASPError.Description() if l_strAspDescription <> "" then response.write("<p>" + l_strAspDescription+ "</p>") end if
l_strAspDescription = "詳細描述:" + objASPError.ASPDescription() if l_strAspDescription <> "" then response.write("<p>" + l_strAspDescription+ "</p>") end if
'------------------------------------------------------------------- Response.Write "</b><br>" End If %> </li> <p> <li>瀏覽器類型:<br> <%= Request.ServerVariables("HTTP_USER_AGENT") %> </li> <p> <li>頁:<br> <% strMethod = Request.ServerVariables("REQUEST_METHOD")
Response.Write strMethod & " "
If strMethod = "POST" Then Response.Write Request.TotalBytes & " bytes to " End If
Response.Write Request.ServerVariables("SCRIPT_NAME")
lngPos = InStr(Request.QueryString, "|")
If lngPos > 1 Then Response.Write "?" & Left(Request.QueryString, (lngPos - 1)) End If
Response.Write "</li>"
If strMethod = "POST" Then Response.Write "<p><li>POST 數據:<br>" If Request.TotalBytes > lngMaxFormBytes Then Response.Write Server.HTMLEncode(Left(Request.Form, lngMaxFormBytes)) & " . . ." Else Response.Write Server.HTMLEncode(Request.Form) End If Response.Write "</li>" End If
%> <p> <li>時間:<br> <% datNow = Now()
Response.Write Server.HTMLEncode(FormatDateTime(datNow, 1) & ", " & FormatDateTime(datNow, 3)) Session.Codepage = bakCodepage %> </li> </p> <p> <li>詳細信息:<br> <%strQueryString = "prd=iis&sbp=&pver=5.0&ID=500;100&cat=" & Server.URLEncode(objASPError.Category) & _ "&os=&over=&hrd=&Opt1=" & Server.URLEncode(objASPError.ASPCode)& "&Opt2=" & Server.URLEncode(objASPError.Number) & _ "&Opt3=" & Server.URLEncode(objASPError.Description) strURL = "http://www.microsoft.com/ContentRedirect.asp?" & _ strQueryString %> <a href="<%= strURL %>">Microsoft 支持</a> </li> </p>
</font></td> </tr>
</body> </html>
|