SharePoint24x7 It's all about SharePoint.

28Dec/110

Enabling Developer Dashboard in SharePoint 2010

ASP.NET provides Call Stack and Tracing as wonderful features which helps developers on investigating what is going on page rendering behind the scene. SharePoint being a product which provides bunch of features OOTB which we can use to setup a portal very easily, it hides most of these information.

Back in MOSS 2007, we had to scratch our head thinking where to start our investigation when we get an error in the browser, because that error was not descriptive enough for us to start the investigation.

In SharePoint 2010, we have a nice feature – Developer Dashboard which helps developers to be comfortable when they see an error in the browser.

Enabling Developer Dashboard

Developer Dashboard is a feature targeted for developers (administrators as well) and hence it is disabled by default. We need to enable it using one of the method mentioned below:

  • STSADM
  • PowerShell
  • SharePoint Object Model
STSADM

We still can use STSADM with SharePoint 2010 for administering SharePoint. However, STSADM is more likely to disappear in the next release. Though we can use following STSADM command to enable Developer Dashboard, I strongly recommend to get familiar with PowerShell, if you are not already.

  1. Go to the command prompt and make sure to either set the path to the location of STSADM.EXE or navigate to the bin directory in SharePoint root in your command prompt.
  2. Issue the following command in the command prompt:STSADM -o setproperty -pn developer-dashboard -pv ondemand

The above command will enable the Developer Dashboard in On Demand mode.

PowerShell
  1. Go to Start –> All Programs –> Microsoft SharePoint 2010 Products –> SharePoint 2010 Management Shell
  2. Issue the following command in the management shell:$devdash = [Microsoft.SharePoint.Administration.SPWebService]::ContentService.DeveloperDashboardSettings;
    $devdash.DisplayLevel = ‘OnDemand’;
    $devdash.TraceEnabled = $true;
    $devdash.Update()

The above command will enable the Developer Dashboard in On Demand mode.

SharePoint Object Model
  1. Create a Console Application, Windows Application or Web Site and add a reference to the Microsoft.SharePoint.dll assembly.
  2. Add using Microsoft.SharePoint.Administration namespace reference at the top of the code (C#) file.
  3. Add the following code into your code (C#) file to enable Developer Dashboard:SPWebService svc = SPContext.Current.Site.WebApplication.WebService;
    svc.DeveloperDashboardSettings.DisplayLevel = SPDeveloperDashboardLevel.OnDemand;
    svc.DeveloperDashboardSettings.Update();

The above command will enable the Developer Dashboard in On Demand mode.

I have used On Demand as the setting for Display Level of the Developer Dashboard and following are the other options we can specify:

  1. On – Enable the Developer Dashboard all the times
  2. Off – Disable the Developer Dashboard
  3. OnDemand – Enable the Developer Dashboard but will be displayed on demand.

When you enable Developer Dashboard in On Demand mode, following icon will be displayed next to your login name.

Capture1

On click of the Developer Dashboard icon, page will be reloaded and Developer Dashboard will be displayed at the bottom of the page as shown below:

Capture2

If you have also used TraceEnabled = $true switch with PowerShell, then you will see a link says “Show or hide additional tracing information …” at the end of the Developer Dashboard which allows you to show/ hide ASP.NET Tracing information as shown below:

Capture3

Isn’t this a awesome feature for you to get started your investigation exercise? Have a closer look at what Developer Dashboard offers you and it will help you in numbers of ways.

Posted by Joy

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

No trackbacks yet.