简体   繁体   English

显示500内部服务器错误的完整详细信息

[英]Show full details of 500 Internal Server Error

How do I see the full error in a page which returns 500 internal error? 如何在页面中看到返回500内部错误的完整错误?

All I see is the error number and description -internal server error- with no exact details of the details of the error? 我看到的只是错误号和描述 - 内部服务器错误 - 没有错误细节的确切细节?

There are several ways to achieve this, though I would recommend setting up ELMAH . 有几种方法可以实现这一点,但我建议设置ELMAH

It will log the exception with stack trace and provide a web interface to see it. 它将使用堆栈跟踪记录异常并提供Web界面以查看它。

There are other loggers ( log4net ) and you can write your own logging ( Exception.ToString() will provide most of the needed information for tracking down a bug), but I find ELMAH to be easy to get going. 还有其他记录器( log4net ),您可以编写自己的日志记录( Exception.ToString()将提供用于追踪错误的大部分所需信息),但我发现ELMAH很容易上手。

Check the error logs. 检查错误日志。 Where they are located is dependent on your serer setup though. 它们所在的位置取决于您的serer设置。

If the error is happening on your ASP.NET app, you can catch the error and email it to yourself. 如果您的ASP.NET应用程序发生错误,您可以捕获错误并通过电子邮件发送给自己。

You can catch the error in the Global.asax file... 您可以捕获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. G。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM