How to detect errors in your own site (allow administrators to sleep)

Source: Internet
Author: User
Tags servervariables sleep domain domain name
Error | Admin Below is based on Wrox Professional ASP 3.0 to establish the site error checking mechanism, after use, you can find a lot of their mistakes, save a lot of code testing time, why not!
First set up the table:

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
First, check the error link of the record website:
Create/siteerror/naverror.asp in the directory of the Web site
________________________________________________

<% @LANGUAGE = "VBScript"%>
<%response.status = "404 Not Found"%>
<!--This is the location of the database connection string-->
<!--#include file= ". /include/connect.asp "-->

<title> Unable to find page </title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<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>
<body bgcolor= "#FFFFFF" text= "#000000" topmargin= "0" >
<table width= "100%" border= "1" cellspacing= "0" cellpadding= "0" height= "#000000" bordercolor= "center" >
<tr>
&LT;TD bgcolor= "#FFFFFF" >
<b><font color= "#999999" > the page you are searching for may have been deleted, renamed, or temporarily unavailable. </font></b>
<%
' On Error Resume Next
Strtarget = Request.ServerVariables ("query_string")
Strreferer = Request.ServerVariables ("Http_referer")

Intsemicolon = InStr (Strtarget, ";") ' Get the original target
If (Intsemicolon > 0) and (Intsemicolon < Len (strtarget)) Then
Strtarget = Mid (strtarget, Intsemicolon + 1)
If Len (strtarget) > 254 Then strtarget = left (strtarget, 254)
End If

If Len (strreferer) > 255 Then strreferer = left (strreferer, 255)

Strinform = "<font style=" "color:000000; font:9pt/11pt "" > Please notify the site administrator that contains the error link. </font> "
strtyping = "<font style=" "color:000000; Font:9pt/11pt "" > If you type the address of a Web page in the Address field, check to see if it is spelled correctly. or:</font> "
Strrecord = "<font style=" "color:000000; font:9pt/11pt song "" > This error has been recorded and will be dealt with as soon as possible. </a> "

Response.Write "<p> cannot find the page address is:" & strtarget & "<P>"
If Len (Strreferer) > 0 Then ' came from a link on another page
Response.Write "<font style=" "color:000000; Font:9pt/11pt "" > The following pages found link errors: "& Strreferer _
& ". </font><BR> "
Set oconn = Server.CreateObject ("ADODB. Connection ") ' to store the details
oConn.Open DSN
strsql= "exec sp_errorrecorder ' broken link ', '" & Strtarget & "', '" &strReferer& ""
Oconn.execute strSQL
Rem Note here
If Err.Number = 0 and InStr (strreferer, "your domain name such as 163.com") > 0 Then
Response.Write Strrecord ' came from a page to our site
Else
Response.Write Strinform ' came from page ' another site
End If
Else
Response.Write Strtyping ' They just typed it wrong into their browser
End If
%>
<!--the connection here is your domain name-->
<p> <a href= "http://your domain name" ><font color= "#993399" > Open home Page </font></a>, find a link to the information you want.
</p>
<p> Click <a href=&qu



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.