大雀软件园

首页 软件下载 安卓市场 苹果市场 电脑游戏 安卓游戏 文章资讯 驱动下载
技术开发 网页设计 图形图象 数据库 网络媒体 网络安全 站长CLUB 操作系统 媒体动画 安卓相关
当前位置: 首页 -> 技术开发 -> ASP专区 -> 如何检测自己网站的错误(让管理员可以睡觉)

如何检测自己网站的错误(让管理员可以睡觉)

时间: 2021-07-31 作者:daque

底下是按照wrox的professional asp 3.0创造的网站缺点查看体制,运用了之后,你不妨找到本人很多的缺点,俭朴洪量的代码尝试功夫,干什么不必呢!开始创造表:create table [dbo].[tsiteerrors] ([kerrkey] [int] identity (1, 1) not null ,[ddatetime] [datetime] not null ,[errortype] [varchar] (255) not null ,[targeturl] [varchar] (255) null ,[errorinfo] [varchar] (255) null ) on [primary]go一、查看记载网站的缺点链接:在网站的目次中创造/siteerror/naverror.asp________________________________________________<%@language="vbscript"%><%response.status = "404 not found" %><!--这边是数据库贯穿字符串的场所--><!--#include file="../include/connect.asp"--><html><head><title>没辙找到网页</title><meta http-equiv="content-type" content="text/html; charset=utf8"><meta name="robots" content="noindex"><style type="text/css"><!--td {font-size: 9pt}a{color:#000000;text-decoration:none;}a:link {color: #000000; text-decoration: none}a:visited {color: #000000; text-decoration: none}a:active {color: #000000; text-decoration: none}a:hover {color: #0c78d1; text-decoration: underline}--></style></head><body bgcolor="#ffffff" text="#000000" topmargin="0"><table width="100%" border="1" cellspacing="0" cellpadding="0" height="95%" bordercolor="#000000" align="center"><tr> <td bgcolor="#ffffff"><h2><b><font color="#993399">  没辙找到网页</font></b></h2><hr><b><font color="#999999"> 您正在探求的网页大概仍旧简略、改名或姑且不行用。</font></b> <% 'on error resume nextstrtarget = request.servervariables("query_string")strreferer = request.servervariables("http_referer")intsemicolon = instr(strtarget, ";") 'get the original targetif (intsemicolon > 0) and (intsemicolon < len(strtarget)) thenstrtarget = mid(strtarget, intsemicolon + 1)if len(strtarget) > 254 then strtarget = left(strtarget, 254)end ifif len(strreferer) > 255 then strreferer = left(strreferer, 255)strinform = "<font style=""color:000000; font: 9pt/11pt 宋体"">请报告包括该缺点链接的网站处置员。</font>"strtyping = "<font style=""color:000000; font: 9pt/11pt 宋体"">即使您在“地方”栏中键入了网页地方,请查看其拼写能否精确。大概:</font>"strrecord = "<font style=""color:000000; font: 9pt/11pt 宋体"">这个缺点仍旧被记载,将尽量获得处置。</a>"response.write "<p>没辙找到的网页地方为:  " & strtarget & "<p>"if len(strreferer) > 0 then'came from a link on another pageresponse.write "<font style=""color:000000; font: 9pt/11pt 宋体"">下列网页中创造了链接缺点: " & strreferer _& " 。</font><br>"set oconn = server.createobject("adodb.connection") 'to store the detailsoconn.open dsnstrsql="exec sp_errorrecorder 'broken link','" & strtarget & "','"&strreferer&"'"oconn.execute strsqlrem 提防这边if err.number = 0 and instr(strreferer, "你的域名 比方163.com") > 0 then response.write strrecord'came from a page on our siteelse response.write strinform'came from a page on another siteend ifelseresponse.write strtyping'they just typed it wrong into their browserend if%><!--这边的贯穿是你的域名--><p> <a href="http://你的域名"><font color="#993399">翻开网页</font></a>,探求指向所需消息的链接。 </p><p> 单击<a href="javascript:history.back(1)"><font color="#0033cc">畏缩</font></a>按钮试验其余链接。</p><hr><p> <a href="http://你的域名"><font color="#993399">你的网站</font></a>创造,看法和倡导请接洽<a href="你的邮件"><font color="#0033cc">你的邮件</font></a> </p><p> </p><p> </p></td></tr><tr><td height="5" bgcolor="#000000"></td></tr></body></html>二、查看记载网站的代码缺点:在网站的目次中创造/siteerror/asperror.asp<%@language="vbscript"%><% response.status="500 internal error"%><!--#include file=../include/connect.asp--><html><head><meta name="robots" content="noindex"><title>效劳器里面缺点</title><meta http-equiv="content-type" content="text/html; charset=utf8"><style type="text/css"><!--td {font-size: 9pt}a{color:#000000;text-decoration:none;}a:link {color: #000000; text-decoration: none}a:visited {color: #000000; text-decoration: none}a:active {color: #000000; text-decoration: none}a:hover {color: #0c78d1; text-decoration: underline}--></style></head><body bgcolor="#ffffff" text="#000000" topmargin="0"><%response.flushon error resume nextset objasperror=server.getlasterror()strerrnumber=cstr(objasperror.number)straspcode=objasperror.aspcodestrerrdescription=objasperror.descriptionstraspdescription=objasperror.aspdescriptionstrcategory=objasperror.categorystrfilename=objasperror.filestrlinenum=objasperror.linestrcolnum=objasperror.columnif isnumeric(strcolnum) then lngcolnum=clng(strcolnum)else lngcolnum=0end ifstrsourcecode=objasperror.sourceset objasperror=nothingif len(strfilename) then strtarget=strfilenameelse strtarget="**file name not available **"end ifif len(straspcode) then strinfo="'" & straspcode & "'"else strinfo="error"end ifif len(strcategory) then strinfo=strinfo & " in " & strcategory & ".<br>"end ifstrinfo=strinfo & "code: " & strerrnumber & "(0x" & hex(strerrnumber) & ") " & strerrdescription & ".<br>"if len(straspdescription) then strinfo=strinfo&"asp reports: '" & straspdescription & "'.<br>"end ifif strlinenum>"0" then strinfo=strinfo & "line " & strlinenum if lngcolnum>0 thenstrinfo=strinfo & ". column " & lngcolnumif len(strsourcecode) then strinfo=strinfo & " " & strsourcecodeend if end ifend ifif len(strtarget) >255 then strtarget=left(strtarget,255)if len(strinfo)>255 then strinfo = left(strinfo,255)strinfo=replace(strinfo,"'","''")set oconn=server.createobject("adodb.connection")oconn.open dsnstrsql="insert into tsiteerrors(errortype,targeturl,errorinfo) values ('asp error','" & strtarget & "','" & strinfo & "')"strsql="exec sp_errorrecorder 'asp error','" & strtarget & "','"&strinfo&"'"oconn.execute strsqloconn.closeset oconn=nothing%><table width="100%" border="1" cellspacing="0" cellpadding="0" height="95%" bordercolor="#000000" align="center"><tr> <td bgcolor="#ffffff"><h2><b><font color="#993399">  效劳器里面缺点</font></b></h2><hr><b><font color="#999999"> 您欣赏的页面展示了效劳器里面缺点,姑且没辙翻开,这个题目仍旧被体例记载,咱们将登时处置该题目。</font></b>  <p> 单击<a href="javascript:history.back(1)"><font color="#0033cc">畏缩</font></a>按钮试验其余链接。</p><hr><p> <a href="http://你的域名"><font color="#993399">你的网站</font></a>创造,看法和倡导请接洽<a href="mailto:你的邮件"><font color="#0033cc">你的邮件</font></a> </p><p> </p><p> </p></td></tr><tr><td height="5" bgcolor="#000000"></td></tr></body></html>三、创造查看缺点的页面:/siteerror/manage_error.asp<%@language="vbscript"%><!-- #include virtual="/include/connect.asp" --><%server.scripttimeout = 900response.expires = 0%><html><head><meta name="robots" content="noindex,nofollow"><title>web-developer site administration</title><style type="text/css">body {font-family:"arial"; font-size:12; font-weight:normal}.intro {font-family:"arial"; font-size:14; font-weight:bold}td {font-family:"arial"; font-size:12; font-weight:normal}th {font-family:"arial"; font-size:12; font-weight:bold; text-align:left}h1 {font-family:"arial"; font-size:24; color:darkgray}</style></head><body bgcolor="#ffffff"><h1>网站缺点查看</h1><hr><span class=intro>处置网站的缺点</span><p><%on error resume next'***********************************************'-- open database connection'***********************************************set oconn = server.createobject("adodb.connection")oconn.open dsn'************************************************'-- delete all items from table'************************************************if len(request.form("deleteall")) thenstrsql = "delete from tsiteerrors"oconn.execute(strsql)if err.number = 0 then response.write "仍旧简略一切缺点<br>"end ifif len(request.form("deletechecked")) then'************************************************'-- delete ticked items from table'************************************************for each chkbox in request.formif left(chkbox, 1) = "x" thenstrtargeturl = mid(chkbox,2)strsql = "delete from tsiteerrors where targeturl='" & strtargeturl & "'"oconn.execute(strsql)if err.number = 0 then response.write "deleted errors for target: <b>" & strtargeturl & "</b><br>"end ifnext'************************************************end if'************************************************'-- display list of errors'************************************************%><p>click on a link to view the source or target page. once the error has been fixed,<br>tick that entry and click the <b>delete selected errors</b> button.<p><form action="<% = request.servervariables("script_name")%>" method="post"><%strsql="select distinct ddatetime, errortype, targeturl, errorinfo from tsiteerrors order by ddatetime desc"set ors = oconn.execute(strsql)if (ors.eof) or (err.number > 0) thenresponse.write "<b>sorry, the database cannot be accessed.</b></body></html>"response.endend if'-- loop through the error recordsintwinnumber = 0 'to create different target window for each linkdo while not ors.eof if ors("errortype") = "broken link" then'-- display broken link details %>the page <a href="<% = ors("errorinfo") %>" target="new_err_win<% = intwinnumber %>"><% = ors("errorinfo") %></a> contains a broken link.<br>target is <a href="<% = ors("targeturl") %>" target="new_err_win<% = intwinnumber + 1 %>"><% = ors("targeturl") %></a><br>date/time: <% = ors("ddatetime") %>     <% else'-- display script error details %>the page <a href="<% = ors("targeturl") %>" target="new_err_win<% = intwinnumber %>"><% = ors("targeturl") %></a> produced an asp error .<br><% = server.htmlencode(ors("errorinfo")) %><br>date/time: <% = ors("ddatetime") %>     <% end if %> <input type="checkbox" name="x<% = server.htmlencode(ors("targeturl")) %>">delete?<p> <% intwinnumber = intwinnumber + 2 ors.movenextloopset ors = nothingset oconn = nothing%><hr><input type="submit" name="deletechecked" value="delete selected errors">    <input type="submit" name="deleteall" value="delete all errors"></form></body></html>四、在internet效劳处置器中树立自设置缺点:在internet效劳处置器中采用属性中的[自设置缺点消息],编纂404[缺点贯穿]的属性,[动静典型]改为url,url改成/siteerror/naverror.asp,编纂500[里面缺点]的属性,[动静典型]改为url,url改为/siteerror/asperror.asp,而后决定。五、此刻你就不妨在http://127.0.0.1/siteerror/manage_error.asp中察看你的缺点的精细材料了,呵呵,如许咱们就不妨一眼看到咱们常犯的初级缺点,而一举把她们祛除,你的网站就会显得“纯洁多了”。

热门阅览

最新排行

Copyright © 2019-2021 大雀软件园(www.daque.cn) All Rights Reserved.