帝国软件
  设为首页 加入收藏 关于我们
 
解密帝国网站管理系统
栏 目:
 
您的位置:首页 > 技术文档 > ASP编程
关于错误信息的显示
作者:赖皮王子 发布时间:2005-03-12 来源:ChinaASP
asp程序出错后,错误提示不是很清楚明白,让人摸不着头脑,用下面方法看看有没有帮助(此法目前只适合处ADO错误外的错误)
步骤一,用编辑器打开c:winnthelpiisHelpcommon500-100.asp
将它另存为500-101.asp备份(以便日后恢复)
步骤二,将下面的代码覆盖500-100.asp原文件,保存退出
步骤三,创建新文件test.asp,添加如下代码
<% response.write now(1)%>,存盘退出
步骤四,在浏览器中输入localhost/test.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">

<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>"
%>
</li>
<p>
<li>错误位置:<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 & " 行")
If objASPError.Column > 0 Then Response.Write ", 第 " & objASPError.Column & " 列"
Response.Write "</b><br>"
End If
%>
</li>
<p>
<li>错误描述:<br>
<%
response.write Server.HTMLEncode(objASPError.description)
%>
</li>
<p>

</body>
</html>


  
评论】【加入收藏夹】【 】【打印】【关闭
※ 相关链接
 ·关于页面缓存清除的方法小结(整  (2005-03-12)
 ·关于客户端用ASP参生报表  (2005-03-12)
 ·关于客户端用ASP参生报表(高级篇  (2005-03-12)
 ·关于ACCESS 2K与ASP的几点想法  (2005-03-12)
 ·关于vbscript 与 javascript如何  (2005-03-12)
 ·关于如何读出图片的高度与长度的  (2005-03-12)
 ·关于生成目录树结构的类  (2005-03-12)
 ·关于处理GET方式提交的含有特殊字  (2005-03-12)
 ·关于处理GET方式提交的含有特殊字  (2005-03-12)
 ·关于IBuySpy里面用户权限验证方面  (2005-03-12)

   栏目导行
  PHP编程
  ASP编程
  ASP.NET编程
  JAVA编程
   站点最新
·致合作伙伴的欢迎信
·媒体报道
·帝国软件合作伙伴计划协议
·DiscuzX2.5会员整合通行证发布
·帝国CMS 7.0版本功能建议收集
·帝国网站管理系统2012年授权购买说
·PHPWind8.7会员整合通行证发布
·[官方插件]帝国CMS-访问统计插件
·[官方插件]帝国CMS-sitemap插件
·[官方插件]帝国CMS内容页评论AJAX分
   类别最新
·在ASP中使用数据库
·使用ASP脚本技术
·通过启动脚本来感受ASP的力量
·学习使用ASP对象和组件
·解析asp的脚本语言
·初看ASP-针对初学者
·ASP开发10条经验总结
·ASP之对象总结
·ASP与数据库应用(给初学者)
·关于学习ASP和编程的28个观点
 
关于帝国 | 广告服务 | 联系我们 | 程序开发 | 网站地图 | 留言板 帝国网站管理系统