How to enable custom error web.config in SharePoint 2013

This SharePoint 2013 tutorial explains, how to enable custom error web.config in SharePoint 2013/2016? This tutorial, I would like to discuss the issue while rendering SharePoint site “Server Error / Application”. We will discuss how we can enable custom error in SharePoint farm solution.

When I was trying to render my SharePoint site I was getting the below error message.

enable custom error web.config sharepoint 2013

Enable custom error web.config SharePoint 2013

The above error message is soo generic and we don’t understand what has happened exactly. To understand the exact issue we need to enable custom errors for this SharePoint web application.

Follow the below steps to understand the error description:

  • Log on to SharePoint server with FARM Administrator account
  • Open IIS with through run prompt with the command “inetmgr”
  • Identify the web application you want to enable error logging
  • Click on Explore on the right panel
  • Open the Web.config file
  • Identify “” tag
  • Change the mode value to “on”
  • Restart IIS
sharepoint 2013 enable custom errors web.config

Now when you open the site you can see the detailed issue in the browser.

Modify web.config for debugging support in SharePoint

Now we will see, what are the modifications needed in web.config file to enable debugging support in SharePoint custom development.

Whenever you start debugging a SharePoint visual studio project, it ask you in a dialog box that, Debugging is not enabled. And it gives two options whether you want to enable debugging (which automatically do changes in web.config file) or you want to run without debugging support as shown in the figure below:

Modify web.config for debugging support in SharePoint

If you choose the first option the it will do below modifications in the web.config file:

  • Set CallStack=”true” in SafeMode attribute.
  • Set customErrors mode=”Off” in the system.web section.
  • compilation debug=”true” in the system.web section.

So the changed part of the web.config file should now look like below:

<configuration>
<SharePoint>
<SafeMode CallStack="true" />
</SharePoint>
<system.web>
<customErrors mode="Off" />
<compilation debug="true" />
</system.web>
</configuration>

Remember this changes should not be there in the production server. There debugging option should be disabled. So the web.config for production server should look like below:

<configuration>
<SharePoint>
<SafeMode CallStack="false" />
</SharePoint>
<system.web>
<customErrors mode="On" />
<compilation debug="false" />
</system.web>
</configuration>

Visual studio automatically update the web.config to support debugging but it did not reverse it back. So for production we have to do manually like above.

You may like following SharePoint 2013 tutorials:

This SharePoint 2013 tutorial explains, how to enable custom error web.config in SharePoint 2013 or in SharePoint 2016.

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.

>