广·西·电·脑·服·务·网                                     设为首页  收藏本站
首 页 IT 报 道 操作系统 硬件学院 软件学院 网络学院 服 务 器 软件下载
DIY经验 数据恢复 维修宝典 电脑保养 故障症状 黑客安全 病毒快报 电脑优化
维修网点 IT 黄 页 网络游戏 大师答疑 网站技术 动漫游戏 服务社区 素材图片
 广西电脑服务网 ·广西最大的电脑服务平台
您现在的位置: 广西电脑维修在线 >> 网站技术 >> ASP技术 >> ASP技巧 >> 网站技术正文
关于错误信息的显示(正宗原创,欢迎转帖),西西
作者:佚名 文章来源:不详 点击数: 更新时间:2007-2-14 14:56:51

asp程序出错后,错误提示不是很清楚明白,让人摸不着头脑,用下面方法看看有没有帮助(此法目前只适合处ADO错误外的错误)
步骤一,用编辑器打开c:\winnt\help\iisHelp\common\500-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>




 
网站技术录入:admin    责任编辑:admin 
  • 上一篇网站技术:

  • 下一篇网站技术:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)

     IT图片报道

    联想D222到货22寸LCD迅速串红市场

    入门超频王!双敏945PL狂跑1200 F

    冠捷春季新品197V+突破高对比上市

    核心500MHz!性价比王者双敏X1650
     IT热点报道

    普通IT报道 联想D222到货22寸LCD迅速串红市场
    推荐IT报道 入门超频王!双敏945PL狂跑1200 FSB!
    推荐IT报道 冠捷春季新品197V+突破高对比上市
    普通IT报道 核心500MHz!性价比王者双敏X1650GT登场!
    普通IT报道 549元双敏945GC主板到货!
    普通IT报道 宏碁笔记本存储王As3683升级送礼!
    普通IT报道 魅族MP3全线暴跌 M6SP4G版不足700
    普通IT报道 OPPO首款顶级4.3寸大屏MP4 A3上市
    普通IT报道 维修服务拯救PC,谁拯救维修服务?
    普通IT报道 影驰8800GTS游戏盒子上市
    关于公司 | 免责声明 | 广告服务 | 招贤纳士 | 联系我们 | 友情链接 | 网站地图 1 2 3
    Copyright@2005 - 2006  http://www.GXF.com.cn  All Right Reserved  
    桂ICP备06002242号

    技术咨询
    22097366
    10231086
    30636841
    技术交流群
    27717914