Showing posts with label Custom Errors. Show all posts
Showing posts with label Custom Errors. Show all posts

Monday, December 14, 2009

Where is SharePoint web.config?

There is a separate web.config file for each Web Application / IIS Website which is running an instance of SharePoint. For example, if Sharepoint, Central Admin and the MySite host are all running as separate Web applications (different Application pools) on separate IIS sites, there will be a web.config file in the root of the virtual directory for each application. There is also a separate web.config file which contains configuration details for the "_layouts", "_catalogs", etc directories of SharePoint sites.

You should not make changes to the web.config file in a production environment, or while in production. Back up your entire SharePoint environment, including all databases prior to commencing any major troubleshooting or configuration changes. You should attempt and test any modifications to the web.config file in a non-production environment which is configured the same as the live environment. Once you are confident the the changes apply the necessary changes if required to the live environment while it is not in use. The IIS Website will automatically reset when the web.config file is saved so changes will be applied immediately. Be sure that you have not left syntax or any other errors in the file before saving changes.

The web.config files are genearally found in the following locations:

  • web.config file in the root folder of each virtual server / IIS Application.

Local_Drive:\Inetpub\wwwroot

This is the usually the file that contains most of the web configuration of a SharePoint site collection. To display full errors you would need to modify this web.config file. There may be one for each of the SharePoint applications running in some cases (MySites, Multiple Portals or Instances of SharePoint, Central Admin, etc.). If this is the case, you will only need to modify the web.config file which is in the root of the virtual directory for the instance of SharePoint which you using. To find out which directory is used by various SharePoint applications/websites, view the properties of the SharePoint website in IIS and from the "Home Directory" tab, the value in the "Local path" field will take you to the directory where the web.config file is for the specific instance of SharePoint / Application in IIS.














  • web.config file used in Web Part resources for the Global Assembly Cache (GAC)
Local_Drive:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\wpresources

  • web.config configuration file(s) for extending other virtual servers
Local_Drive:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\CONFIG

  • web.config file which defines configuration settings for the /_vti_bin virtual directory
Local_Drive:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\ISAPI
  • web.config file which defines configuration settings for the /_layouts virtual directory
Local_Drive:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\TEMPLATE\LAYOUTS

  • web.config configuration file for Central Administration pages.
Local_Drive:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\TEMPLATE\ADMIN\Locale_ID

SharePoint Web.Config: How to Show Full Errors

Enable display of error details and stack trace when an error occurs

Replace the following error messages with a more meaningful description of the cause of the error by disabling custom errors and enabling the track trace to be displayed as well.

An unexpected error has occurred

An error occurred during the processing of...

To display full errors and the stack trace of the error, you need to modify the web.config file for the Web Application which SharePoint is running on. There are a number of web.config files required to configure various components of SharePoint. For help finding the correct web.config file, see Where is SharePoint web.config? See notes below for more information about modifying the web.config file to display errors.




Enable Custom Errors: Set the customErrors mode to "Off"


Find:

<system.web> ...

<customErrors mode="On" />

Change To:

<system.web> ...

<customErrors mode="Off" />



Enable the Call Stack Trace: Set the CallStack value of the SafeMode element to "true"

Find:

<SharePoint>

<SafeMode ... CallStack="false" ... >

</SharePoint>


Change To:

<SharePoint>

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

</SharePoint>



Enable Debugging Mode: Set batch and debug to "true"

Find: <compilation batch="false" debug="false">
Change To: <compilation batch="true" debug="true">


Enable the ASP.NET tracing feature:
Include the following line in the <system.web> element of the web.config file.

<system.web> ...

<trace enabled="true" pageOutput="true"/>



By default, SharePoint will only display a basic message to users when an error occurs. The message is virtually useless when trying to troubleshoot an issue, so by enabling more descriptive errors to display, including the stack trace which should help you find the cause of the error. You should not make changes to the web.config file in a production environment, or while in production. Back up your entire SharePoint environment, including all databases prior to commencing any major troubleshooting. You should attempt to replicate and resolve the problem in a non-production environment, and apply the necessary changes to the live environment when it is not in production. In many cases, the web.config will not need to be modified in the live environment as the cause of an error will be known after troubleshooting in a production environment.

For more information about the web.config file, where to find it and which one needs to be modified, see
Where is SharePoint web.config?


Related: