Uncovering True Errors in SharePoint (and other .NET web applications)

Have you ever come across an error like this?

image

Or perhaps one similar to this?

image

Unfortunately, these types of “unexpected error” messages do not provide any level of detail as to the actual problem, but instead, only inform you, the admin, there was some type of error that prevented the expected page from coming up properly.

When this happens, there are two changes I make in the application’s web.config file, which have always helped uncover the true problem.

To show the call stack:

Change

<SafeMode MaxControls="200" CallStack="false"
DirectFileDependencies="10" TotalFileDependencies="50"
AllowPageLevelTrace="false">

to

<SafeMode MaxControls="200" CallStack="true"
DirectFileDependencies="10" TotalFileDependencies="50"
AllowPageLevelTrace="false">

To turn custom errors off, so the error and the call stack can be shown:

Change

<customErrors mode="On" />

to

<customErrors mode="Off" />

I’ve seen others mentioning the need to change AllowPageLevelTrace="false" to AllowPageLevelTrace="true", however, I have not had to do this with SharePoint thus far.

One you’ve saved your web.config, the appdomain will be torn down and reloaded on the next incoming request (this happens automatically upon any change to the web.config, by design) and you should be ready to find out your true error.