1、將C:\inetpub\custerr\zh-CN\500-100.asp文件復制到你的站點文件夾下;
2、將這個文件修改為utf-8編碼:
a. 頭部加上 @codepage=65001;
c. 將“<META HTTP-EQUIV="Content-Type"Content="text/html;charset=gb2312">”修改為“<METAHTTP-EQUIV="Content-Type" Content="text/html;charset=utf-8">”;
3. 配置IIS7。
a. 打開IIS7,選擇你建立的站點,在右邊窗口雙擊“錯誤頁”圖標,選擇右邊屬性窗口下的“添加...”操作。
b. 添加自定義錯誤頁窗口中,狀態代碼“500.100”。這里本來我想參照IIS6設置為500-100,結果系統提示不通過。
響應操作,我們這里選擇“在此網站上執行URL”,URL地址“/siteName/500-100.asp”(siteName為你的虛擬站點名稱),如果建立的站點,這里只要輸入相對於站點根目錄的URL地址。
4. 確定后,這樣站點顯示的出錯信息有會詳細的描述了。
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <% 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 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <HTML><HEAD><TITLE>無法顯示該頁</TITLE> <META HTTP-EQUIV="Content-Type" Content="text/html; charset=utf-8"> <STYLE type="text/css"> BODY { font: 8pt/12pt verdana } H1 { font: 13pt/15pt verdana } H2 { font: 8pt/12pt verdana } A:link { color: red } A:visited { color: maroon } </STYLE> </HEAD><BODY><TABLE width=500 border=0 cellspacing=10><TR><TD>
<!--<h1>無法顯示該頁</h1> 您嘗試訪問的頁面有問題,無法顯示。 <hr> <p>請嘗試以下操作:</p> <ul> <li>與網站管理員聯系,告知對方此 URL 地址出現了此錯誤。</li> </ul> <h2>HTTP 500.100 - 內部服務器錯誤: ASP 錯誤。<br>Internet Information Services</h2>--> <hr> <p>技術信息(針對支持人員)</p> <ul> <li>錯誤類型:<br> <% Dim bakCodepage on error resume next ' bakCodepage = Session.Codepage ' Session.Codepage = 65001 on error goto 0 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>" elseIf (objASPError.Description > "") Then Response.Write Server.HTMLEncode(objASPError.Description) & "<br>" end if 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 (strServerIP = strRemoteIP) And objASPError.File <> "?" Then Response.Write Server.HTMLEncode(objASPError.File) If objASPError.Line > 0 Then Response.Write ", line " & objASPError.Line If objASPError.Column > 0 Then Response.Write ", column " & objASPError.Column Response.Write "<br>" Response.Write "<font style=""COLOR:000000; FONT: 8pt/11pt courier new""><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>" & Server.HTMLEncode( objASPError.File) If objASPError.Line > 0 Then Response.Write Server.HTMLEncode(", line " & objASPError.Line) If objASPError.Column > 0 Then Response.Write ", column " & objASPError.Column Response.Write "</b><br>" End If %> </li>
<!--<li>瀏覽器類型:<br> <%= Server.HTMLEncode(Request.ServerVariables("HTTP_USER_AGENT")) %> <br><br></li>--> <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") Response.Write "</li>" If strMethod = "POST" Then Response.Write "<p><li>POST Data:<br>" ' On Error in case Request.BinaryRead was executed in the page that triggered the error. On Error Resume Next If Request.TotalBytes > lngMaxFormBytes Then Response.Write Server.HTMLEncode(Left(Request.Form, lngMaxFormBytes)) & " . . ." Else Response.Write Server.HTMLEncode(Request.Form) End If On Error Goto 0 Response.Write "</li>" End If %> <br><br></li> </ul> <hr> </TD></TR></TABLE></BODY></HTML>
