Saturday, June 26, 2010

SharePoint 2010 - Application Page runtime error "Server Error in "/" Application"

Scenario:

I have developed an application page in SharePoint 2010. After deploying it as a solution, I got the below error:

Server Error in '/' Application. 
--------------------------------

Runtime Error

<!-- Web.Config Configuration File -->

<configuration>
  <system.web>
    <customErrors mode="Off"/>
  </system.web>
</configuration> 

Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.

<!-- Web.Config Configuration File -->

<configuration>
  <system.web>
    <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
  </system.web>
</configuration> 

So, I went in and turn customError and StackTrace option, in web.config on; and then, I got a more detailed error :). Runtime Error with the description telling me that I need to set customError and StackTrace on to see the message. This sound very recursive and very strange. Since, I could not see this error that is why I try to turn on by changing customError and StackTrace on and now they are both on, I am suddenly getting the message telling me to do so in place of the SharePoint custom error.

Explanation:

In SharePoint 2010, depending on what we do, we may need to also edit the web.config in the layouts folder of the SharePoint root:
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\web.config

5 comments:

  1. Good tip. It helped. But scared me since this change is on a SharePoint system file.

    ReplyDelete
  2. editing web.config file located at "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\" is not recommended as whenever a patch is installed in future it will override this file and all the changes will be lost.

    ReplyDelete
    Replies
    1. Right..!! You can add in "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\web.config", when interlinked web.config
      But, Try to keep the changes with web Application's web.config only, so that it is easy to imitate them in other web apps and also as Sumit mentioned the changes can be prevented getting override.

      Delete
  3. yes it helped me, thank you. @Sumeet Shah -> are there other possibilities?

    ReplyDelete