Ok, this might seem confusing, but basically, its this:
There's a form on an asp page (not .net), which sends info to a MS SQL 2000 based server, running on IIS6 (I think, it might be IIS 5.1). The server is configured to only accept digits, but the form is not validated.
So when the user keys in alphabets, and submits, an error is displayed. I have configured IIS to redirect to a different page based on the http error code, ("sorry, the page you requested cannot be loaded at this time"), but now I, as a developer, don't know what the error code is all about.
Is there a way I can configure the error page to 'OnLoad' send an email containing the page address that caused the error, the error message itself, time of error, current user that's logged in, etc.? I'm open to any solutions, client side javascript, or server side asp code... Even IIS configs are valid answers now.. Lol...
In IIS, Custom Errors tab > change the 500 error to type URL file 'error.asp'
In the error.asp, you could loop the form, querystring and session elements and also send the error details to home in on the error.
Dim ASPErr ,ASPErrStr,intKey
Dim strQueryStringElement,strQueryStringValue,strCurrentQueryString
Dim strFormElement,strFormValue,strCurrentForm
Dim strSessElement,strSessValue,strCurrentSess
Set ASPErr = Server.GetLastError()
ASPErrStr = ""
ASPErrStr = ASPErrStr&vbcrlf&"ASPCode: "&ASPErr.ASPCode
ASPErrStr = ASPErrStr&vbcrlf&"ASPDescription: "&ASPErr.ASPDescription
ASPErrStr = ASPErrStr&vbcrlf&"Category: "&ASPErr.Category
ASPErrStr = ASPErrStr&vbcrlf&"Column: "&ASPErr.Column
ASPErrStr = ASPErrStr&vbcrlf&"Description: "&ASPErr.Description
ASPErrStr = ASPErrStr&vbcrlf&"File: "&ASPErr.File
ASPErrStr = ASPErrStr&vbcrlf&"Line: "&ASPErr.Line
ASPErrStr = ASPErrStr&vbcrlf&"Number: "&ASPErr.Number
ASPErrStr = ASPErrStr&vbcrlf&"Source: "&ASPErr.Source
For Each intKey in Request.QueryString
strQueryStringElement = Request.QueryString.Key(intKey)
strQueryStringValue = Request.QueryString.Item(strQueryStringElement)
strCurrentQueryString = strCurrentQueryString & "Element: "& _
strQueryStringElement & ".........Value: " &strQueryStringValue& VBCRLF
Next
For Each intKey in Request.Form
strFormElement = Request.Form.Key(intKey)
strFormValue = Request.Form.Item(strFormElement)
strCurrentForm = strCurrentForm & "Element: "& _
strFormElement & ".........Value: " &strFormValue&VBCRLF
Next
For Each intKey in Session.Contents
strSessElement = intKey
strSessValue = Session(intKey)
strCurrentSess = strCurrentSess & "Element: "& _
strSessElement & ".........Value: " &strSessValue& vbcrlf
Next
ASPErrStr = ASPErrStr&vbcrlf&"QueryString: "
ASPErrStr = ASPErrStr&vbcrlf&strCurrentQueryString
ASPErrStr = ASPErrStr&vbcrlf&"Form: "
ASPErrStr = ASPErrStr&vbcrlf&strCurrentForm
ASPErrStr = ASPErrStr&vbcrlf&"Session: "
ASPErrStr = ASPErrStr&vbcrlf&strCurrentSess
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Error"
myMail.From="someone@address.com"
myMail.To="someoneelse@address.com"
myMail.TextBody= ASPErrStr
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
'Name or IP of remote SMTP server
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtpserveraddress"
'Server port
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25
myMail.Configuration.Fields.Update
myMail.Send
set myMail=nothing
%>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.