1

在本地,应用程序错误执行良好(捕获错误然后将其放入数据库或通过邮件发送)。但是当我将它添加到我们的网站时,它不会执行 application_error 下的代码。任何帮助为什么它不会触发?

Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)




    Dim cookie As HttpCookie = Current.Request.Cookies("id")
    Dim Code As HttpCookie = Current.Request.Cookies("code")
    Dim ErrorMsg() As String
    If cookie Is Nothing Then
    Else

        Dim cDBConnection As clsDBConnection = New clsDBConnection(GetConnection, enumEgswFetchType.DataReader)
        If IsNothing(Code.Value) Then
            ErrorMsg = {0, Request.UserHostAddress.ToString, Me.Session.SessionID, Context.Request.RawUrl, Date.Now, Server.GetLastError.GetBaseException.Message, Server.GetLastError.GetBaseException.GetType.ToString, Server.GetLastError.GetBaseException.Data.ToString, Server.GetLastError.GetBaseException.Source, Server.GetLastError.GetBaseException.TargetSite.ToString, Server.GetLastError.GetBaseException.StackTrace}
            cDBConnection.InsertErrorLog(ErrorMsg(0), ErrorMsg(1), ErrorMsg(2), ErrorMsg(3), ErrorMsg(4), ErrorMsg(5), ErrorMsg(6), ErrorMsg(7), ErrorMsg(8), ErrorMsg(9), ErrorMsg(10))
            Response.Redirect("~/Error.aspx")
        Else
            ErrorMsg = {Code.Value, Request.UserHostAddress.ToString, cookie.Value, Context.Request.RawUrl, Date.Now, Server.GetLastError.GetBaseException.Message, Server.GetLastError.GetBaseException.GetType.ToString, Server.GetLastError.GetBaseException.Data.ToString, Server.GetLastError.GetBaseException.Source, Server.GetLastError.GetBaseException.TargetSite.ToString, Server.GetLastError.GetBaseException.StackTrace}

            cDBConnection.InsertErrorLog(ErrorMsg(0), ErrorMsg(1), ErrorMsg(2), ErrorMsg(3), ErrorMsg(4), ErrorMsg(5), ErrorMsg(6), ErrorMsg(7), ErrorMsg(8), ErrorMsg(9), ErrorMsg(10))
             Response.Redirect("~/Error.aspx")
        End If
        'End If

    End If


End Sub
4

0 回答 0