Wednesday, March 18, 2009

How to Turn Off SharePoint Custom Error Message and Display Stack and Page Output Trace

When error occurs in SharePoint, by default the following error message is displayed:


To see the "true" description of the ASP.NET errors along with the Stack and Page Output Trace messages, the following steps are required:

  • In Windows Explorer, browse to the following folder: C:\inetpub\wwwroot\wss\VirtualDirectories\{SharePoint Port Number} 
  • Double-click the SharePoint web.config file.
  • In the SharePoint web.config file, look for <customErrors mode="On" /> tag and change it to <customErrors mode="Off" /> - this enables the detailed ASP.NET errors to be shown to the remote clients and to the local host (You can also set the mode value to "RemoteOnly" so that the remote clients can see the Custom Error Message and the local host is shown with detailed ASP.NET errors.).
  • In the SharePoint web.config file, locate the <SafeMode MaxControls="200" CallStack="false" tag and change it to <SafeMode MaxControls="200" CallStack="true" - this enables you to received ASP.NET exception messages with stack trace information.
  • Next, in the <system.web> element, add the following line <trace enabled="true" pageOutput="true"/> - this enables you to use the tracing feature in ASP.NET to monitor the page output and environment variables of the local host.
  • Save and close the file.

You will no longer see the SharePoint Custom Error Message page instead you get the "true" & "lovely" standard ASP.NET error page with the stack and page output trace as shown below:


SharePoint development has got that little bit easier!!.. I would recommend only making the following changes in a development environment and not production environment...

1 comment:

Turboman said...

thanks! atucally helpful article.