2

如何查看返回 500 内部错误的页面中的完整错误?

我看到的只是错误号和描述-内部服务器错误-没有错误详细信息的确切细节?

4

3 回答 3

6

有几种方法可以实现这一点,但我建议设置ELMAH

它将使用堆栈跟踪记录异常并提供一个 Web 界面来查看它。

还有其他记录器(log4net),您可以编写自己的日志记录(Exception.ToString()将提供跟踪错误所需的大部分信息),但我发现 ELMAH 很容易上手。

于 2011-01-24T10:15:27.447 回答
1

检查错误日志。它们的位置取决于您的服务器设置。

于 2011-01-24T10:14:07.980 回答
1

如果错误发生在您的 ASP.NET 应用程序上,您可以捕获错误并将其通过电子邮件发送给自己。

您可以在 Global.asax 文件中捕获错误...

    Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
    ' Code that runs when an unhandled error occurs

    Dim sb As New StringBuilder
    sb.AppendFormat("Page Location: {0}", Context.Request.RawUrl)
    With Server.GetLastError.GetBaseException
        sb.AppendFormat("Message: {0}", .Message)
        sb.AppendFormat("Source: {0}", .Source)
        sb.AppendFormat("Method: {0}", .TargetSite)
        sb.AppendFormat("Stack Trace: {0}", .StackTrace)
    End With
    Dim ErrorMsg As String = sb.ToString()
    ' Post thee error to a logger...

End Sub

G。

于 2011-01-24T10:24:55.883 回答