设为首页 收藏本站
查看: 1339|回复: 5

[经验分享] 让IIS中提示错误更加生动(asp)

[复制链接]

尚未签到

发表于 2017-2-12 14:12:43 | 显示全部楼层 |阅读模式
让IIS中提示错误更加生动(asp)
作者:西风剑 阅读:8 次 时间:2004-10-13 来源:稳步网络
  默认的IIS 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="' + escape(urlresult) + '">' + displayresult + "</a>");
}
//-->
</script>
  <body bgcolor="FFFFFF">
  <table width="100%" 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="100%" colspan="2">
<font style="COLOR:000000; FONT: 9pt 宋体">试图访问的网页出现问题,无法显示。</font></td>
</tr>

<tr>
<td width="100%" 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 & " 行") & "<br>"
'读去错误行文本
Dim AppPath,FileName,ErrLine,ErrCode,fs,f,i
AppPath=Request.ServerVariables("APPL_PHYSICAL_PATH")
FileName=Request.ServerVariables("SCRIPT_NAME")
FileName=Replace(FileName,"/","\")
FileName=Mid(FileName,2,Len(FileName)-1)
'Response.Write AppPath & FileName & "<br>"
'常量定义
Const ForReading = 1,TristateFalse = 0
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile(AppPath & FileName,ForReading,TristateFalse)
ErrLine=objASPError.Line
For i = 1 to ErrLine-1
f.SkipLine
Next
ErrCode=f.ReadLine
f.close
Response.Write "<b>该代码出现错误,请检查→</b><font color='#FF0000'>" & ErrCode & "</font><br>"
set fs=nothing
End if
If objASPError.Column > 0 Then Response.Write ", 第 " & objASPError.Column & " 列"
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") & "<br>"
  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>

</table>
</body>
</html>

  请保存成500-100.asp文件,并放置到winnt/iishelp/help/common目录下
  Win2000 Server IIS5.0调试通过

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-341171-1-1.html 上篇帖子: 安装IIS时出现"安装程序无法复制文件zClientm.exe"情况的解决方法 下篇帖子: C#列表所有IIS站点以及相关站点属性
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表