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.

链接地址: http://www.djcxy.com/p/49222.html

上一篇: 由于302重定向到错误页面,搜索引擎无法为asp.net网站编制索引

下一篇: 如何根据请求跟踪ASP.NET?