28

mvc-mini-profiler(http://code.google.com/p/mvc-mini-profiler/)を使い始めたばかりですが、すばらしいと思います。ただし、使用中に奇妙な動作が発生します。

IIS7.5でASP.NETWebformsサイトを実行していますが、何らかの理由でプロファイラーを有効にしてページをロードすると、aspxページの時間測定値を取得するだけでなく、ランダムcssとランダム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);
        }
    }

この動作は予想されますか?

4

2 に答える 2

45

はい、これは正しいですが、これらを除外するのは非常に簡単です。

プロジェクトのサンプルコードから取得ソース

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();
}

これにより、見たいものを除外できます。これは、Webアプリケーションで除外したもののサンプルであり、アプリケーションで機能していることがわかります。

ignored.Add("WebResource.axd");
ignored.Add("ScriptResource.axd");
ignored.Add("/Styles/");
ignored.Add("/Images/");
ignored.Add(".js");
于 2011-07-11T13:09:00.400 に答える
1

実際にそれを1行にまとめて、スラッシュを省略することもできます。このような:

    protected void Application_BeginRequest()
    {
        if (Request.IsLocal)
        {
            MiniProfiler.Start();
            MiniProfiler.Settings.IgnoredPaths = new[] { "static", "webresource.axd", "styles", "images" };
        }
     }
于 2013-12-04T18:31:59.533 に答える