我刚刚开始使用 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);
}
}
这种行为是预期的吗?