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

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

有帮助吗?

解决方案

有几种方法可以实现这一目标,尽管我建议设置 Elmah.

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

还有其他伐木者(log4net),您可以编写自己的记录(Exception.ToString() 将提供大多数需要追踪错误的所需信息),但是我发现Elmah很容易开始。

其他提示

检查错误日志。它们所在的位置取决于您的Serer设置。

如果错误在您的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。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top