关于错误信息的显示 (转)

本文介绍了一种修改ASP错误页面的方法,通过替换500-100.asp文件中的默认代码,可以使得ASP程序出错时显示更详细的错误信息,包括错误类型、位置及描述等。

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

关于错误信息的显示 (转)[@more@] ASP 程序出错后,错误提示不是很清楚明白,让人摸不着头脑,用下面方法看看有没有帮助(此法目前只适合处ADO错误外的错误)
步骤一,用编辑器打开c:winnthelpiisHelpcommon500-100.asp
将它另存为500-101.asp 备份(以便日后恢复)
步骤二,将下面的代码覆盖500-100.asp原 文件,保存退出
步骤三,创建新文件test.asp,添加如下代码
,存盘退出
步骤四,在 浏览器中输入localhost/test.asp查看结果

500-100.asp的新代码:
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
%>
A href="tag-88-1.html">w3c//DTD HTML 3.2 Final//EN">


本页出错



//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( '' + displayresult + "");
}
//--&gt


  • 错误类型:

    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) & ")" ) & "
    "

    If objASPError.ASPDescription > "" Then Response.Write Server.HTMLEncode(objASPError.ASPDescription) & "
    "
    %>



错误位置:

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 "
"
Response.Write ""
Response.Write Server.HTMLEncode(objASPError.Source) & "
"
If objASPError.Column > 0 Then Response.Write String((objASPError.Column - 1), "-") & "^
"
Response.Write "
"
blnErrorWritten = True
End If
End If

If Not blnErrorWritten And objASPError.File <> "?" Then
Response.Write ""
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 & " 列"
Response.Write "

"
End If
%>



错误描述:

response.write Server.HTMLEncode(objASPError.description)
%>



来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10752043/viewspace-990453/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/10752043/viewspace-990453/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值