Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I trace ASP.NET on a per request basis

How can I trace ASP.NET on a per request basis. I know I can turn on application analysis/performance on and see all sorts of statistics on which methods get hit, how long is spent in each, however, I would like to generate similar reports on a per request basis. Short of turning application analysis on and off per request, is there a good tool to do this?

I am on VS2008 (with resharper), IIS7, ASP.NET, .NET 3.5 and Windows 7-64

like image 233
Matt Avatar asked Dec 06 '10 23:12

Matt


1 Answers

You should be able to turn on trace functionality at the page level. This has been available since ASP.NET 1.1 and you turn it on by adding the property to the page directive - eg.

<%@ Page Language="vb" AutoEventWireup="false" Trace="true" Codebehind="whatever.aspx.vb" Inherits="Example.Whatever"%>

You can turn it on from the code behind as well. I usually put it in the code behind on the page load event so I can enable it based on a custom query-string attribute.

If Request.QueryString("trace") = "true" Then
     Trace.IsEnabled = True
  End If

Of course this code should be removed before deploying to production.

I am not sure if that is what you are looking for - since you mention reports and tracing is usually used as a debugging tool but it has a lot of information you can use for troubleshooting page performance.

like image 126
Nikhil Avatar answered Oct 01 '22 10:10

Nikhil