Tuesday, June 2, 2009

Show detailed error message in SharePoint

Exceptions that are caught by SharePoint are generally displayed in a friendly error message instead of a detailed error message with stack trace.

To display the full exception needed for debugging make the following changes to your SharePoint site’s web.config file (Inetpub\wwwroot\wss\VirtualDirectories\[respective Port Number]\web.config).

· Find: <SafeMode CallStack="true" />
· Replace with: <SafeMode CallStack="false" />

· Find: <customErrors mode="On" />
· Replace with: <customErrors mode="On" />

· Find: <compilation debug="false" />
· Replace with: <compilation debug="false" />

Reproduce the problem and the true exception will be displayed.

Application pages beneath _layouts have a separate web.config file that needs updated to enable more detailed error messages.

Open \Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\web.config

Add the following XML block immediately after the <configuration element.

<SharePoint>
<SafeMode CallStack="true">
<PageParserPaths></PageParserPaths>
</SafeMode>
</SharePoint>

· Find: <compilation debug="false" />
· Replace with: <compilation debug="true" />

Note: Always remember to disable debug mode before deploying a production application or conducting any performance measurements. If debug mode is enabled, the performance of your application can suffer a great deal.

0 comments: