Enable Developer Dashboard for anonymous users


SharePoint 2010 contains Developer Dashboard which can be invaluable in optimizing custom solutions for performance. By default the Developer Dashboard is visible only to authenticated users, but sometimes you might want to show it to anonymous users as well. Sounds insane? Find out why you would want it and how to do it.

Monitoring page performance with Developer Dashboard

Developer Dashboard in SharePoint 2010 is a great way of monitoring the performance of custom solutions. Using no more than three lines of code you can measure the execution time of your code. Developer Dashboard allows you to display those values on your website so that you don’t have to examine the ULS log.

By default Developer Dashboard is visible to a subset of authenticated users only. You have to have at least the AddAndCustomizePages permission to see the Developer Dashboard. This is understandable: after all, you don’t want everyone to see the internal information.

Developer Dashboard for everybody

Although the default approach of showing Developer Dashboard to specific users only is enough in most scenarios, there are situations where you might want to change this. Building Internet-facing solutions on the SharePoint 2010 platform is one example of such scenarios.

Imagine that you are working on an Internet-facing website that will be visible to anonymous users. Having wrapped your code in SPMonitoredScope you can see its performance in Developer Dashboard. In your solution there is some code which executes differently for anonymous and authenticated users.

Execution time of a custom Web Part rendered for authenticated users. Execution time is low.

While the default configuration of Developer Dashboard allows you to examine how well it is working with authenticated users, how can you check if the code is still fast enough with anonymous users? And this is exactly why you might want to enable Developer Dashboard to all users including anonymous visitors.

You can change which users can see Developer Dashboard using PowerShell. First you need a reference to Developer Dashboard Settings:

$contentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
$dashboardSettings = $contentService.DeveloperDashboardSettings

Next you have to change the value of the RequiredPermissions property which is by default set to AddAndCustomizePages. In order to make Developer Dashboard visible to all users you have to change the value of the RequiredPermissions property to EmptyMask:

$dashboardSettings.RequiredPermissions = [Microsoft.SharePoint.SPBasePermissions]::EmptyMask
$dashboardSettings.Update()

When you navigate to your website now without logging in, the Developer Dashboard toggle button should be visible and you should be able to enable Developer Dashboard. And with that you should be able to examine the performance of your custom code for both anonymous and authenticated users.

Execution time of a custom Web Part rendered for anonymous users. Execution time is high.

One more thing

Enabling Developer Dashboard for anonymous users can help you discover problem areas in your solution and is definitely something you should do on your development environment when working on solutions that will be available to anonymous users. You shouldn’t however enable Developer Dashboard for anonymous users on your production environment as it can contain internal data about your environment that might be use to hack your environment.

Technorati Tags: SharePoint 2010

Others found also helpful: