迷你MVC探查:似乎每一个静态资源被显示的资料倍 [英] Mini MVC profiler: appears to be displaying profile times for every static resource
问题描述
我使用MVC-迷你探查刚开始( HTTP ://$c$c.google.com/p/mvc-mini-profiler/ ),我认为这是真棒。不过,我得到,而使用它的一些奇怪的行为。
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.
我有一个ASP.NET Web表单网站上IIS7.5出于某种原因,当我加载一个页面启用了Profiler运行,我不仅得到了aspx页面时间测量,但我也得到它在页面上随机CSS和JS资源。
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.
在ASPX轮廓正常工作,使用SQL查询也正在正确的异形。然而,随着图为我也得到了一堆这似乎是静态的CSS和JS文件结果的其他结果。据我所知,这些正在担任了由静态IIS,所以探查code甚至不应该调用这些。
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.
我的Global.asax的相关部分是:
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?
推荐答案
是的,这是正确的,但它很容易将这些过滤掉。
Yes this is correct but it is very easy to filter these out.
href=\"https://$c$c.google.com/p/mvc-mini-profiler/source/browse/Sample.WebForms/Global.asax.cs\">Source
Taken from the sample code in the project Source
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
// some things should never be seen
var ignored = MiniProfiler.Settings.IgnoredPaths.ToList();
ignored.Add("WebResource.axd");
ignored.Add("/Styles/");
MiniProfiler.Settings.IgnoredPaths = ignored.ToArray();
}
这可以让你筛选出你想看到什么,或者这是不是什么我已经排除其中我发现正在为我的应用程序
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
ignored.Add("WebResource.axd");
ignored.Add("ScriptResource.axd");
ignored.Add("/Styles/");
ignored.Add("/Images/");
ignored.Add(".js");
这篇关于迷你MVC探查:似乎每一个静态资源被显示的资料倍的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!