See actual SharePoint error exception modify web.config


Posted on : Fri, 16th Oct 15 08:46 pm UTC
2314 votes

SharePoint errors and exceptions

Whenever something goes wrong in SharePoint, you are greeted with a non-useful error message like below -

SharePoint 2007 - An unexpected error has occurred.

SharePoint 2010 - An unexpected error has occurred.

SharePoint 2013 - Sorry, something went wrong.

Display meaningful and developer friendly error

Make following changes to the corresponding web.config file of your site by following below steps.

  1. Navigate to the virtual directory of your web application (usually located at C:\inetpub\wwwroot\wss\VirtualDirectories). For example, if your site is hosted on port 80 then open the folder 80.
  2. Locate web.config file and create a backup (backup is very important, just in case something goes wrong)
  3. Open the web.config in any editor which you are comfortable (Notepad, Notepad++, WordPad, EditPlus, Word, etc). Visual Studio will be my preferred editor.
  4. Locate the tag <SafeMode>. There is an attribute CallStack which is set to False by default. Set this attribute to True. This will allow SharePoint to enable stack trace and display the actual details of error/exception.
  5. Locate the tag <customErrors>. There is an attribute mode which is set to On by default. Set this attribute to Off. This will enable custom errors instead of showing user friendly messages.
  6. Refresh the page with error and now you should see more details which are useful to the developer for troubleshooting.

This is how your changes should look.

<SafeMode CallStack="true" ............... >

<customErrors mode="Off" />

Important : This is recommended only in Development environments and you should not fiddle with the web.config in production environments. The purpose of enabling and custom errors and complete stack trace is only for easier troubleshooting and developers are recommended to revert the changes once development is completed.

Code2care's mission is to share varied knowledge in technical and non-technical areas gathered during day-to-day learnings and development activities so that our visitors can leverage this portal to find solutions to their queries without re-inventing the wheel. Technical posts include Learnings, Tutorials, Video Tutorials, Code Snippets, Tips-n-tricks.

Follow us : Facebook - Twitter - Google +