迷你 MVC 分析器:似乎显示每个静态资源的分析时间
我刚刚开始使用 mvc-mini-profiler (http://code.google .com/p/mvc-mini-profiler/),我认为这很棒。但是,我在使用它时遇到了一些奇怪的行为。
我有一个在 IIS7.5 上运行的 ASP.NET Webforms 站点,由于某种原因,当我加载启用了探查器的页面时,我不仅获得了 aspx 页面的时间测量,而且还获得了随机 css 和页面上的js资源。
aspx 配置文件工作正常,SQL 查询也能正确配置。然而,如图所示,我还得到了一堆其他结果,这些结果似乎是静态 CSS 和 JS 文件的结果。据我所知,这些是由 IIS 静态提供的,因此甚至不应该为这些调用探查器代码。
我的 Global.asax 的相关部分是:
protected void Application_BeginRequest()
{
MiniProfiler profiler = null;
// might want to decide here (or maybe inside the action) whether you want
// to profile this request - for example, using an "IsSystemAdmin" flag against
// the user, or similar; this could also all be done in action filters, but this
// is simple and practical; just return null for most users. For our test, we'll
// profile only for local requests (seems reasonable)
profiler = MiniProfiler.Start();
using (profiler.Step("Application_BeginRequest"))
{
// you can start profiling your code immediately
}
}
protected void Application_EndRequest()
{
MvcMiniProfiler.MiniProfiler.Stop();
}
protected void Application_AuthenticateRequest(object sender, EventArgs e)
{
if (User == null || !User.Identity.IsAuthenticated)
{
MvcMiniProfiler.MiniProfiler.Stop(true);
}
}
这种行为是预期的吗?
I've just started using the mvc-mini-profiler (http://code.google.com/p/mvc-mini-profiler/) and I think it's awesome. However, I'm getting some odd behaviour while using it.
I've got an ASP.NET Webforms site running on IIS7.5 and for some reason when I load a page with the profiler enabled, I not only get a time measurement for the aspx page, but I also get it for random css and js resources on the page.
The aspx profile works correctly, with the SQL query also being profiled correctly. However, as the picture shows I also get a bunch of other results which appear to be results for static CSS and JS files. As far as I can tell, these are being served up statically by IIS, so the profiler code shouldn't even be invoked for these.
The relevant parts of my Global.asax are:
protected void Application_BeginRequest()
{
MiniProfiler profiler = null;
// might want to decide here (or maybe inside the action) whether you want
// to profile this request - for example, using an "IsSystemAdmin" flag against
// the user, or similar; this could also all be done in action filters, but this
// is simple and practical; just return null for most users. For our test, we'll
// profile only for local requests (seems reasonable)
profiler = MiniProfiler.Start();
using (profiler.Step("Application_BeginRequest"))
{
// you can start profiling your code immediately
}
}
protected void Application_EndRequest()
{
MvcMiniProfiler.MiniProfiler.Stop();
}
protected void Application_AuthenticateRequest(object sender, EventArgs e)
{
if (User == null || !User.Identity.IsAuthenticated)
{
MvcMiniProfiler.MiniProfiler.Stop(true);
}
}
Is this behaviour expected?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,这是正确的,但是很容易过滤掉这些。
取自项目中的示例代码 来源
这可以让你过滤掉你想看或不想看的内容,这是我在我的网络应用程序中排除的内容的示例,我发现它适用于我的应用程序
Yes this is correct but it is very easy to filter these out.
Taken from the sample code in the project Source
This lets you filter out what you want to see or not this is a sample of what I have excluded in my web application which i am finding is working for my application
实际上,您可以将其放在一行中,并且省略斜杠。像这样:
You can actually put that in one line and also omit the slashes. Like this: