本文來(lái)自:https://blog.csdn.net/chengshiruxia/article/details/43526001
感謝原創(chuàng)的奉獻(xiàn)!
網(wǎng)站為utf-8編碼時(shí)IIS環(huán)境下運(yùn)行出錯(cuò)時(shí)iis給出的提示亂碼解決方法,本方法本人試個(gè)絕對(duì)可行,asp出錯(cuò)時(shí)iis亂碼最終解決辦法,utf-8編碼網(wǎng)站出錯(cuò)iis提示亂碼主要是因?yàn)镮IS7的錯(cuò)誤信息輸出默認(rèn)使用的是GB2312編碼,這樣會(huì)導(dǎo)致IIS7出現(xiàn)運(yùn)行時(shí)錯(cuò)誤的信息會(huì)是亂碼,影響我們糾錯(cuò)
在調(diào)試站點(diǎn)環(huán)境時(shí),如果系統(tǒng)開(kāi)發(fā)編碼使用的是UTF-8,iis錯(cuò)誤提示亂碼解決方法。
1、將C:\inetpub\custerr\zh-CN\500-100.asp文件復(fù)制到你的站點(diǎn)文件夾下;
2、將這個(gè)文件另存為utf-8編碼:
a. 頭部加上 @codepage=65001; 如:<%@ language="VBScript" @codepage=65001 %>
b. option explicit后面加上一行response.charset="utf-8";
c. 將“<META HTTP-EQUIV="Content-Type" Content="text/html; charset=gb2312">”修改為“<META HTTP-EQUIV="Content-Type" Content="text/html; charset=utf-8">”;
3. 配置IIS。
a. 打開(kāi)IIS,選擇你建立的站點(diǎn),在右邊窗口雙擊“錯(cuò)誤頁(yè)”圖標(biāo),選擇右邊屬性窗口下的“添加...”操作。
b. 添加自定義錯(cuò)誤頁(yè)窗口中,狀態(tài)代碼“500.100”。這里本來(lái)我想?yún)⒄誌IS6設(shè)置為500-100,結(jié)果系統(tǒng)提示不通過(guò)。響應(yīng)操作,我們這里選擇“在此網(wǎng)站上執(zhí)行URL”,URL地址“/siteName/500-100.asp”(siteName為你的虛擬站點(diǎn)名稱),如果建立的站點(diǎn),這里只要輸入相對(duì)于站點(diǎn)根目錄的URL地址。
4. 確定后,這樣utf-8編碼站點(diǎn)顯示的出錯(cuò)信息有會(huì)詳細(xì)的描述了不會(huì)是亂碼了。
示例:
-
<%@ language="VBScript" @codepage=65001 %>
-
<%
-
Option Explicit
-
response.charset="utf-8"
-
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>無(wú)法顯示該頁(yè)</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>無(wú)法顯示該頁(yè)</h1>
-
您嘗試訪問(wèn)的頁(yè)面有問(wèn)題,無(wú)法顯示。
-
<hr>
-
<p>請(qǐng)嘗試以下操作:</p>
-
<ul>
-
<li>與網(wǎng)站管理員聯(lián)系,告知對(duì)方此 URL 地址出現(xiàn)了此錯(cuò)誤。</li>
-
</ul>
-
<h2>HTTP 500.100 - 內(nèi)部服務(wù)器錯(cuò)誤: ASP 錯(cuò)誤。<br>Internet Information Services</h2>
-
<hr>
-
<p>技術(shù)信息(針對(duì)支持人員)</p>
-
<ul>
-
<li>錯(cuò)誤類型:<br>
-
<%
-
Dim bakCodepage
-
on error resume next
-
bakCodepage = Session.Codepage
-
Session.Codepage = 1252
-
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>頁(yè)面:<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>
-
<li>時(shí)間:<br>
-
<%
-
datNow = Now()
-
Response.Write Server.HTMLEncode(FormatDateTime(datNow, 1) & ", " & FormatDateTime(datNow, 3))
-
on error resume next
-
Session.Codepage = bakCodepage
-
on error goto 0
-
%>
-
<br><br></li>
-
<li>詳細(xì)信息:<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
-
%>
-
<ul>
-
<li>單擊 <a href="<%= strURL %>">Microsoft 支持</a>,可以找到有關(guān)此錯(cuò)誤的文章鏈接。</li>
-
<li>轉(zhuǎn)到 <a href="http://go.microsoft.com/fwlink/?linkid=8180" target="_blank">Microsoft 產(chǎn)品支持服務(wù)</a>,執(zhí)行標(biāo)題搜索,查找詞語(yǔ) <b>HTTP</b> 和 <b>500</b>。</li>
-
<li>打開(kāi) <b>IIS 幫助</b>(可從 IIS 管理器(inetmgr)訪問(wèn)),搜索主題<b>網(wǎng)站管理</b>和<b>關(guān)于自定義錯(cuò)誤消息</b>。</li>
-
<li>在 IIS 軟件開(kāi)發(fā)包(SDK)中,或者在 <a href="http://go.microsoft.com/fwlink/?LinkId=8181">MSDN 聯(lián)機(jī)庫(kù)</a>中,搜索主題<b>調(diào)試 ASP 腳本</b>、<b>調(diào)試組件</b>和<b>調(diào)試 ISAPI 擴(kuò)展功能和篩選器</b>。</li>
-
</ul>
-
</li>
-
</ul>
-
-
</TD></TR></TABLE></BODY></HTML>
html