简体   繁体   English

如何基于每个请求跟踪ASP.NET

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

How can I trace ASP.NET on a per request basis. 如何基于每个请求跟踪ASP.NET。 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 我在VS2008(使用resharper),IIS7,ASP.NET,.NET 3.5和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. 从ASP.NET 1.1开始就可以使用它,并通过将属性添加到页面指令来启用它 - 例如。

<%@ 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. 如果上面的跟踪选项不是您要查找的,则可以尝试的另一个选项是在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. 我没有自己使用它,所以你的YMMV,但如果你感兴趣的话,这是一篇关于IIS.NET的好文章的链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在ASP.NET MVC中基于每个用户删除输出缓存? - How can I remove the output cache on a per-user basis in ASP.NET MVC? 在 Asp.net 内核中根据每个请求决定是否使用授权 - Deciding to use Authorization or not on a per-request basis in Asp.net Core ASP.NET应用程序如何基于每个API强制实施HTTPS? - How could an ASP.NET application enforce HTTPS on a per-API basis? ASP.NET MVC上的Windows Identity Framework-如何基于操作授权用户? - Windows Identity Framework on ASP.NET MVC - how to authorize user per action basis? ASP.NET C#:缓存数据库结果,何时/如何无效(基于每个记录) - ASP.NET C#: Caching Database Results, When/How Invalidate (on per-record basis) 在ASP.NET MVC3中,我如何看到请求? - in ASP.NET MVC3 how can I see the request? 如何在 ASP.net 核心中按请求缓存 - How to Per-Request caching in ASP.net core 如何在 ASP.NET 中限制每个请求 memory 的使用? - How to limit per-request memory usage in ASP.NET? ASP.NET MVC按请求注入 - ASP.NET MVC inject per request 如何根据asp.net C#下拉菜单中的用户输入在图表上添加一条直线 - How can I add a straight line on my chart on the basis of user input from drop down menu in asp.net c#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM