Global.asax中的Application_Error不会触发

时间:2013-03-26 00:17:42

标签: asp.net vb.net global-asax

本地应用程序错误执行正常(捕获错误然后将其放入数据库或通过邮件发送)。但是当我将它添加到我们的网站时,它不会执行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

0 个答案:

没有答案
相关问题