欢迎光临
我们一直在努力

让你的错误提示更生动-ASP教程,ASP应用

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

默认的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调试通过

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 让你的错误提示更生动-ASP教程,ASP应用
分享到: 更多 (0)

相关推荐

  • 暂无文章