0

我在共享主机上运行我的应用程序。

当我在开发服务器上运行最新更改时,一切正常 - 当我上传时,我看到通用的“发生错误但未显示”消息。

如果我将 web.config 更改为包含

CustomErrors mode="off"

然后我仍然看到相同的错误消息。

我猜我最近的一项更改是在解析 web.config 时导致问题。

有什么方法可以检索此错误的详细信息?我知道的唯一方法是事件日志和服务器日志——我都无法访问。

非常感谢您的帮助


这是将来节省其他所有人时间的代码。将格式化异常详细信息并邮寄。如果 Global.asax 不存在,请添加它。然后更新 Application_Error 方法。

    Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
    ' Code that runs when an unhandled error occurs
    Dim ex As Exception = Server.GetLastError().GetBaseException()
    Dim ErrMsg As New Text.StringBuilder

    While ex IsNot Nothing
        ErrMsg.AppendLine(String.Format("Message : {0}", ex.Message))
        ErrMsg.AppendLine(String.Format("Source : {0}", ex.Source))
        ErrMsg.AppendLine(String.Format("Target : {0}", ex.TargetSite.ToString))
        ErrMsg.AppendLine("Stack: ")
        ErrMsg.AppendLine(ex.StackTrace)

        If ex.InnerException IsNot Nothing Then
            ex = ex.InnerException
            ErrMsg.AppendLine(">> Inner Exception >>>>>>>>>>>>>>>>>>>>>")
        Else
            ex = Nothing
        End If

    End While

    Try
        Dim Message As New System.Net.Mail.MailMessage
        Message.Body = ErrMsg.ToString

        Message.Subject = "MPW Error"
        Message.To.Add(New MailAddress("EMAIL_ADDRESS_HERE@example.com"))
        Dim SMTP As New SmtpClient
        SMTP.Send(Message)

    Catch FatalEx As Exception
        'Write to file, die or re-throw
    End Try
End Sub
4

1 回答 1

1

就是方法。

于 2009-11-06T20:06:04.977 回答