gpt4 book ai didi

javascript - 如果IIS 6根据错误重定向到另一个页面,如何确定错误?

转载 作者:行者123 更新时间:2023-12-03 09:00:46 25 4
gpt4 key购买 nike

好的,这似乎令人困惑,但是基本上,这是这样的:

在ASP页面(不是.net)上有一个表单,该表单将信息发送到运行在IIS6上的基于MS SQL 2000的服务器(我认为可能是IIS 5.1)。服务器被配置为仅接受数字,但表单未经验证。

因此,当用户键入字母并提交时,将显示错误。我已经将IIS配置为根据http错误代码重定向到另一个页面(“抱歉,您的请求的页面目前无法加载”),但是现在,作为开发人员,我不知道错误代码是什么关于一切。

有没有一种方法可以将错误页面配置为“加载”,以发送一封电子邮件,其中包含导致错误的页面地址,错误消息本身,错误时间,登录的当前用户等?我愿意接受任何解决方案,客户端javascript或服务器端的asp代码...现在甚至IIS配置都是有效的答案..大声笑...

最佳答案

在IIS中,“自定义错误”选项卡>将500错误更改为键入URL文件“error.asp”

在error.asp中,您可以循环使用表单,querystring和session元素,还可以将错误详细信息发送到错误所在的位置。

    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
%>

关于javascript - 如果IIS 6根据错误重定向到另一个页面,如何确定错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5101365/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com