سؤال

How do I see the full error in a page which returns 500 internal error?

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.

It will log the exception with stack trace and provide a web interface to see it.

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.

نصائح أخرى

Check the error logs. Where they are located is dependent on your serer setup though.

If the error is happening on your ASP.NET app, you can catch the error and email it to yourself.

You can catch the error in the Global.asax file...

    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