LOGO OA教程 ERP教程 模切知识交流 PMS教程 CRM教程 开发文档 其他文档  
 
网站管理员

utf-8编码出错iis错误提示乱码解决方法

liguoquan
2025年8月20日 17:25 本文热度 397
:utf-8编码出错iis错误提示乱码解决方法


utf-8编码出错iis错误提示乱码解决方法

转载于 2018-08-04 13:17:04 发布·2.8k 阅读
·0
· 1
文章标签:

#IIS配置

 本文介绍了解决IIS7环境下UTF-8编码网站出现乱码问题的方法。通过调整500-100.asp文件编码及配置IIS错误页,实现错误信息的正常显示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

本文来自:https://blog.csdn.net/chengshiruxia/article/details/43526001

感谢原创的奉献!

网站为utf-8编码时IIS环境下运行出错时iis给出的提示乱码解决方法,本方法本人试个绝对可行,asp出错时iis乱码最终解决办法,utf-8编码网站出错iis提示乱码主要是因为IIS7的错误信息输出默认使用的是GB2312编码,这样会导致IIS7出现运行时错误的信息会是乱码,影响我们纠错

在调试站点环境时,如果系统开发编码使用的是UTF-8,iis错误提示乱码解决方法。

1、将C:\inetpub\custerr\zh-CN\500-100.asp文件复制到你的站点文件夹下;  


2、将这个文件另存为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. 打开IIS,选择你建立的站点,在右边窗口双击“错误页”图标,选择右边属性窗口下的“添加...”操作。  
b. 添加自定义错误页窗口中,状态代码“500.100”。这里本来我想参照IIS6设置为500-100,结果系统提示不通过。响应操作,我们这里选择“在此网站上执行URL”,URL地址“/siteName/500-100.asp”(siteName为你的虚拟站点名称),如果建立的站点,这里只要输入相对于站点根目录的URL地址。 
4. 确定后,这样utf-8编码站点显示的出错信息有会详细的描述了不会是乱码了。

 

示例:

  1. <%@ language="VBScript" @codepage=65001 %>
  2. <%
  3.  Option Explicit
  4.  response.charset="utf-8"
  5.  Const lngMaxFormBytes = 200
  6.  Dim objASPError, blnErrorWritten, strServername, strServerIP, strRemoteIP
  7.  Dim strMethod, lngPos, datNow, strQueryString, strURL
  8.  If Response.Buffer Then
  9.    Response.Clear
  10.    Response.Status = "500 Internal Server Error"
  11.    Response.ContentType = "text/html"
  12.    Response.Expires = 0
  13.  End If
  14.  Set objASPError = Server.GetLastError
  15. %>
  16. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  17. <HTML><HEAD><TITLE>无法显示该页</TITLE>
  18. <META HTTP-EQUIV="Content-Type" Content="text/html; charset=utf-8">
  19. <STYLE type="text/css">
  20.  BODY { font: 8pt/12pt verdana }
  21.  H1 { font: 13pt/15pt verdana }
  22.  H2 { font: 8pt/12pt verdana }
  23.  A:link { color: red }
  24.  A:visited { color: maroon }
  25. </STYLE>
  26. </HEAD><BODY><TABLE width=500 border=0 cellspacing=10><TR><TD>
  27. <h1>无法显示该页</h1>
  28. 您尝试访问的页面有问题,无法显示。
  29. <hr>
  30. <p>请尝试以下操作:</p>
  31. <ul>
  32. <li>与网站管理员联系,告知对方此 URL 地址出现了此错误。</li>
  33. </ul>
  34. <h2>HTTP 500.100 - 内部服务器错误: ASP 错误。<br>Internet Information Services</h2>
  35. <hr>
  36. <p>技术信息(针对支持人员)</p>
  37. <ul>
  38. <li>错误类型:<br>
  39. <%
  40.  Dim bakCodepage
  41.  on error resume next
  42. bakCodepage = Session.Codepage
  43. Session.Codepage = 1252
  44.  on error goto 0
  45.  Response.Write Server.HTMLEncode(objASPError.Category)
  46.  If objASPError.ASPCode > "" Then Response.Write Server.HTMLEncode(", " & objASPError.ASPCode)
  47.    Response.Write Server.HTMLEncode(" (0x" & Hex(objASPError.Number) & ")" ) & "<br>"
  48.  If objASPError.ASPDescription > "" Then
  49. Response.Write Server.HTMLEncode(objASPError.ASPDescription) & "<br>"
  50.  elseIf (objASPError.Description > "") Then
  51. Response.Write Server.HTMLEncode(objASPError.Description) & "<br>"
  52.  end if
  53.  blnErrorWritten = False
  54.  ' Only show the Source if it is available and the request is from the same machine as IIS
  55.  If objASPError.Source > "" Then
  56.    strServername = LCase(Request.ServerVariables("SERVER_NAME"))
  57.    strServerIP = Request.ServerVariables("LOCAL_ADDR")
  58.    strRemoteIP =  Request.ServerVariables("REMOTE_ADDR")
  59.    If (strServerIP = strRemoteIP) And objASPError.File <> "?" Then
  60.      Response.Write Server.HTMLEncode(objASPError.File)
  61.      If objASPError.Line > 0 Then Response.Write ", line " & objASPError.Line
  62.      If objASPError.Column > 0 Then Response.Write ", column " & objASPError.Column
  63.      Response.Write "<br>"
  64.      Response.Write "<font style=""COLOR:000000; FONT: 8pt/11pt courier new""><b>"
  65.      Response.Write Server.HTMLEncode(objASPError.Source) & "<br>"
  66.      If objASPError.Column > 0 Then Response.Write String((objASPError.Column - 1), "-") & "^<br>"
  67.      Response.Write "</b></font>"
  68.      blnErrorWritten = True
  69.    End If
  70.  End If
  71.  If Not blnErrorWritten And objASPError.File <> "?" Then
  72.    Response.Write "<b>" & Server.HTMLEncode(  objASPError.File)
  73.    If objASPError.Line > 0 Then Response.Write Server.HTMLEncode(", line " & objASPError.Line)
  74.    If objASPError.Column > 0 Then Response.Write ", column " & objASPError.Column
  75.    Response.Write "</b><br>"
  76.  End If
  77. %>
  78. </li>
  79. <li>浏览器类型:<br>
  80. <%= Server.HTMLEncode(Request.ServerVariables("HTTP_USER_AGENT")) %>
  81. <br><br></li>
  82. <li>页面:<br>
  83. <%
  84.  strMethod = Request.ServerVariables("REQUEST_METHOD")
  85.  Response.Write strMethod & " "
  86.  If strMethod = "POST" Then
  87.    Response.Write Request.TotalBytes & " bytes to "
  88.  End If
  89.  Response.Write Request.ServerVariables("SCRIPT_NAME")
  90.  Response.Write "</li>"
  91.  If strMethod = "POST" Then
  92.    Response.Write "<p><li>POST Data:<br>"
  93.    ' On Error in case Request.BinaryRead was executed in the page that triggered the error.
  94.    On Error Resume Next
  95.    If Request.TotalBytes > lngMaxFormBytes Then
  96.      Response.Write Server.HTMLEncode(Left(Request.Form, lngMaxFormBytes)) & " . . ."
  97.    Else
  98.      Response.Write Server.HTMLEncode(Request.Form)
  99.    End If
  100.    On Error Goto 0
  101.    Response.Write "</li>"
  102.  End If
  103. %>
  104. <br><br></li>
  105. <li>时间:<br>
  106. <%
  107.  datNow = Now()
  108.  Response.Write Server.HTMLEncode(FormatDateTime(datNow, 1) & ", " & FormatDateTime(datNow, 3))
  109.  on error resume next
  110. Session.Codepage = bakCodepage
  111.  on error goto 0
  112. %>
  113. <br><br></li>
  114. <li>详细信息:<br>
  115. <%  
  116.  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)
  117.  strURL = "http://www.microsoft.com/ContentRedirect.asp?" & strQueryString
  118. %>
  119.  <ul>
  120.  <li>单击 <a href="<%= strURL %>">Microsoft 支持</a>,可以找到有关此错误的文章链接。</li>
  121.  <li>转到 <a href="http://go.microsoft.com/fwlink/?linkid=8180" target="_blank">Microsoft 产品支持服务</a>,执行标题搜索,查找词语 <b>HTTP</b><b>500</b></li>
  122.  <li>打开 <b>IIS 帮助</b>(可从 IIS 管理器(inetmgr)访问),搜索主题<b>网站管理</b><b>关于自定义错误消息</b></li>
  123.  <li>在 IIS 软件开发包(SDK)中,或者在 <a href="http://go.microsoft.com/fwlink/?LinkId=8181">MSDN 联机库</a>中,搜索主题<b>调试 ASP 脚本</b><b>调试组件</b><b>调试 ISAPI 扩展功能和筛选器</b></li>
  124.  </ul>
  125. </li>
  126. </ul>
  127. </TD></TR></TABLE></BODY></HTML>
html

该文章在 2025/8/20 17:25:38 编辑过
关键字查询
相关文章
正在查询...
点晴ERP是一款针对中小制造业的专业生产管理软件系统,系统成熟度和易用性得到了国内大量中小企业的青睐。
点晴PMS码头管理系统主要针对港口码头集装箱与散货日常运作、调度、堆场、车队、财务费用、相关报表等业务管理,结合码头的业务特点,围绕调度、堆场作业而开发的。集技术的先进性、管理的有效性于一体,是物流码头及其他港口类企业的高效ERP管理信息系统。
点晴WMS仓储管理系统提供了货物产品管理,销售管理,采购管理,仓储管理,仓库管理,保质期管理,货位管理,库位管理,生产管理,WMS管理系统,标签打印,条形码,二维码管理,批号管理软件。
点晴免费OA是一款软件和通用服务都免费,不限功能、不限时间、不限用户的免费OA协同办公管理系统。
Copyright 2010-2025 ClickSun All Rights Reserved