Custom errors in web.config and SharePoint 2010

Now with SharePoint 2010 it’s not as straight forward as in SharePoint 2007 to enable custom errors to show up in the browser. While in 2007 you needed to enable the settings in one web.config file we have now the same settings but at different locations.

If you need more detailed information than in the following screen you went to the virtual directory under IIS and changed the web.config for your web application:

Unhandled exception was thrown by the sandboxed code wrapper's Execute method in the partial trust app domain: An unexpected error has occurred.

Custom errors in web.config and SharePoint 2010 are enabled.

What you needed to change:

<customErrors mode="Off" />
<SafeMode MaxControls="200" CallStack="true"...

These changes have always worked back in 2007 since there was only one place which settings applied to all pages in SharePoint 2007.

This has changed in SharePoint 2010.

Depending on the web site you have opened using SharePoint 2010 you might see the following error:

Runtime Error 
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".

Custom errors in web.config and SharePoint 2010 are still enabled.

This is due to an additional web.config file in the SharePoint 2010 14 hive. So at the end you need to change the following web.config files depending on the location an error occured:

  1. \inetpub\wwwroot\wss\VirtualDirectories\<YOUR_DIRECTORY>

Just search for web.config under the 14 hive and you will find 45 different web.config files with the RTM version of SharePoint 2010. You don’t need to enable everything at once… some custom error settings are already set to off like in the web.config under “\14\TEMPLATE\ADMIN“. Just remember if you see the runtime error that there are different locations to check…