In Focus

How to Debug SharePoint 2013 Using Client-Side Request Tracing

This article exlains how to debug SharePoint 2013 using Client-Side Request Tracing.

In some circumstances, it can be useful to monitor HTTP requests and responses from a client computer. One of the main advantages of this approach is that it enables you to view all the HTTP traffic generated by a specific page request. This can help you to diagnose a range of problems, such as:
  • Slow load times on specific webpages.
  • Partial request failures, such as images not displaying.
  • Unexpected caching behaviors.
  • Issues downloading resources from Content Delivery Networks (CDNs).
There are a range of tools that you can use to do this kind of client-side request tracing. For example, Fiddler is a popular freeware tool that provides a range of request monitoring and debugging functionality. For simple request tracing, you can use the F12 Developer Tools that are built into Internet Explorer. In Internet Explorer 9 and Internet Explorer 10, F12 Developer Tools includes a Network tab that enables you to capture all the HTTP traffic you generate from the browser window. If you start a request tracing session and then browse to a webpage—on a SharePoint site or on any other website—you may be surprised by the amount of traffic your single page request generates. A single request to a webpage will typically result in many more requests for images, JavaScript files, CSS files, possibly together with calls to services or advertising content. All client-side tracing tools will provide a detailed breakdown of these requests, with timings, response codes and various other details for each request. This breakdown can help you to isolate the causes of slow page load times and other page load issues.
 
Using the Developer Dashboard

Capturing and analyzing network traffic can help you diagnose a range of problems, but it does not provide any insight into how SharePoint generates and renders specific pages. To investigate more complex issues, you can use the SharePoint Developer Dashboard to provide detailed insights into the page build process and code execution behind individual page requests. The Developer Dashboard was introduced in SharePoint 2010, but it has been completely redesigned for SharePoint 2013. It now runs in a separate window so that it does not interfere with the page itself. It uses a dedicated Windows Communication Foundation (WCF) service, Diagnosticsdata.svc, to retrieve results. At the top level, the Developer Dashboard provides a breakdown of individual requests in a similar way to client-side tracing tools. For each of these individual requests, you can view the following additional information:
  • Server info. This tab displays general information about the request, such as the start time, duration, CPU time, memory and correlation ID associated with the request.

  •  Scopes. This tab provides a breakdown of how long the request spends at each point in the call stack.

  •  SQL. This tab provides details of any database calls made during the processing of the request.

  •  SPRequests. This tab provides details of any background requests that occurred in addition to the page request.

  • Asserts. This tab identifies any assert calls made during the request. Assert calls are used by developers to write details of unexpected conditions to an output window.

  •  Service Calls. This tab provides details of any calls to web services made during the request.

  •  ULS. This tab contains all the trace log entries associated with the current request.

  •  Cache Calls. This tab provides details of any cache calls made during the request.
Enabling and disabling the Developer Dashboard

To make the Developer Dashboard available, open the SharePoint 2013 Management Shell and run the following commands.

Enabling the Developer Dashboard 
  1. $content = ([Microsoft.SharePoint.Administration.SPWebService]::ContentService)  
  2. $appsetting = $content.DeveloperDashboardSettings  
  3. $appsetting.DisplayLevel =  
  4. [Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel]::On  
  5. $appsetting.Update()  
After you enable the Developer Dashboard, SharePoint adds an icon to the upper-right corner of every page. You can launch the Developer Dashboard by clicking the icon. To disable the Developer Dashboard, open the SharePoint 2013 Management Shell and run the following commands.

Disabling the Developer Dashboard
  1. $content = ([Microsoft.SharePoint.Administration.SPWebService]::ContentService)  
  2. $appsetting = $content.DeveloperDashboardSettings  
  3. $appsetting.DisplayLevel =  
  4. [Microsoft.SharePoint.Administration.SPDeveloperDashboardLevel]::Off  
  5. $appsetting.Update()