简体   繁体   中英

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

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.

Another option you can try if the Trace option above is not what you are looking for is to turn failed request tracing in IIS 7.0. I haven't used it myself so your YMMV but in case you are interested here is a link to a good article on IIS.NET about it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM