簡體   English   中英

如果IIS 6根據錯誤重定向到另一個頁面,如何確定錯誤?

[英]How to determine error if IIS 6 is redirecting to a different page based on error?

好的,這似乎令人困惑,但是基本上,這是這樣的:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM