欢迎光临
我们一直在努力

关于错误信息的显示(正宗原创,欢迎转帖),西西

建站超值云服务器,限时71元/月

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>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 关于错误信息的显示(正宗原创,欢迎转帖),西西
分享到: 更多 (0)