2

I am using MiniProfiler v3.2.0.157 and MiniProfiler.EF6 v3.0.11 with C# for an ASP.NET MVC 4 website. While I can get the profiler to show up on the majority of the pages on the site, it does not show up on the landing page.

I have tried everything suggested here: MiniProfiler not showing up on asp.net MVC and here: Using MiniProfiler with MVC 5 with no success.

Update: I also tried the Donut Caching Technique described here: Donut hole caching - exclude MiniProfiler.RenderIncludes

I have noticed that for the pages that do work, if there is a breakpoint in Application_BeginRequest right on MiniProfiler.Start(), MiniProfiler.Current has a value for on requests for most of our pages, but in the case of a request for our landing page, it is null at this point. There does not appear to be anything special about the Landing page that would cause problems.

The important parts of my code are show below.

Global.asax.cs:

protected void Application_BeginRequest(Object sender, EventArgs e)
    {
        if (Request.IsLocal)
        {
            MiniProfiler.Start();
        }


    }

protected void Application_EndRequest()
    {             

        MiniProfiler.Stop(discardResults: false);

    }

Web.config:

<system.webServer>
    <handlers>
      <add name="MiniProfiler" path="mini-profiler-resources/*" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />
    </handlers>
  </system.webServer>

Layout Page:

@using StackExchange.Profiling;
<head>
    ...
</head>
<body>
    ...
    @MiniProfiler.RenderIncludes()
</body>

Landing Page Controller:

using StackExchange.Profiling;
...
public ActionResult Landing()
    {
        var profiler = MiniProfiler.Current;

        using (profiler.Step("Content Controller Landing"))
        {
            var user = ...;
            return View(...);
        }

    }
Community
  • 1
  • 1
tstuart
  • 21
  • 6
  • Well that's fun. If you out a break point on the MiniProfiler.Start(), does it hit for those pages? Is it possible that this is an [OutputCache] thing? – Marc Gravell Jun 01 '16 at 21:30
  • Answering because I'm on the same team - yes it hits MiniProfiler.Start() in all cases, but immediately after, just for that one page, MiniProfiler.Current is still null. I'll look into [OutputCache] thing, no idea – jackmott Jun 01 '16 at 22:27
  • @MarcGravell I don't think it is an [OutputCache] thing specifically, because we don't call it for any of the functions that are involved with the landing page. The problem though does sound like it could be something similar to that. – tstuart Jun 02 '16 at 16:25

1 Answers1

0

Here is my answer MiniProfiler not showing up on asp.net MVC

Conclusion, be sure you added the code in Application_Start()

protected void Application_Start()
{
    ...
    MiniProfiler.Configure(new MiniProfilerOptions());//default setting
    MiniProfilerEF6.Initialize();
}

See official document : https://miniprofiler.com/dotnet/AspDotNet

Jim
  • 489
  • 5
  • 11