Showing posts with label customErrors. Show all posts
Showing posts with label customErrors. Show all posts

29 December, 2013

Quick Fixes 1 :Avoiding the Default Custom Error Page in Sharepoint 2010

Hi Guys,

This is my first post on Amol's SharePoint Knowledge Base Blog . I will be starting my posts off with a Quick Fixes Series . The purpose of this series will be to provide immediate solutions to several niggles and quirks in SharePoint that we face on an everyday basis . I will not be diving in depth into the mechanics . Its intended to be a quick solution to your issues.

Lets get started !!

We all of us in development have faced the nagging issue at some point in time of the Default Custom Error Page, this occurs when we have deployed some new code related to web parts or event receivers , or in general for several issues , including deletion of content types etc. 



Before we run into the SharePoint ULS Logs or the event viewer or worse yet start debugging the code let's take a moment and let SharePoint show us the actual error.

Step 1:

The first step we need to take is to the change the web.config in the virtual directory of the web application which should ideally be present under a path similar to this : inetpub\wwwroot\wss\Virtual directories folder\[Central Admin PortNo]\web.config

Inside this web.config we should the following entry <customErrors> mode . This attribute will be having a value "On" . We need to change it to "Off" . Make sure you type it in the same way , the words are case-sensitive.

Step 2:

Next we need to find an attribute  <SafeMode> CallStack in the same web.config as above . This will be having a value of "false". We need to go ahead and change it to "true".

Step 3(Optional) :

Next we need to find an attribute Debug . It should be having the value "false" by default . Go ahead and change this to "true".

So the 3 changes are :
  1. CustomErrors=”Off” instead of the default CustomErrors=”On” 
  2. CallStack=”true” instead of the default CallStack=”false”
  3. Debug=”true” instead of the default Debug=”false”
Once these 3 steps are done we should ideally see a more usable page such as the one shown below :


As you can see this is a much better page . We can go ahead and google the error from here and try and find a relevant fix.

Note: 

It is very possible that even after above 3 steps we are still not able to see the error details .
In this case below are a few more troubleshooting steps that you can use to trace or view the error.

Additional Step 1:

There is another web.config present in the SharePoint hive under the _layouts folder . The layouts folder can be found under the path: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14

Modify this web.config similar to Step 1 to have the customErrors attribute set as "Off"



Additional Step 2:
If the above does not work then we have another web.config present at the path : C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\ADMIN\
Go ahead and change the customErrors attribute to "Off" in this one as well

These 2 steps should definitely show you the detailed error page in your application if the first 3 haven't already worked.

In addition you can try and enable the default ASP.NET trace to view the errors as well.
This is done by going to web.config again in the virtual directory of your web application i.e the one at :inetpub\wwwroot\wss\Virtual directories folder\[Central Admin PortNo]\web.config

Here find the <system.web> element of the web.config file .

Under this element add the following line : <trace enabled=”true” pageOutput=”true”/>

This will give you some errors traced by ASP.NET trace as well . However this will be useful only when combined with all the above steps.

IMPORTANT NOTE : Please do not forget to perform an IISRESET after all the changes as sometimes the changes in web.config do not reflect by themselves.

Perform an IISRESET and refresh your error page and i sincerely hope you can view a more explicable page than the one you started with . 

Good Luck and watch out for more Quick Fixes from my end. 

Don't forget to comment and ask your queries in the comment section . I'll get back with my comments ASAP.