Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MiniProfiler not showing up in ASP.NET Core

I'm trying to plumb MiniProfiler into my ASP.NET Core MVC web app. I'm not using Entity Framework, I'm using Dapper.

Following the sample app, here are my changes:

  1. Added to Startup.cs ConfigureServices

    services.AddMiniProfiler();

  2. Added to Startup.cs Configure

    app.UseMiniProfiler(new MiniProfilerOptions { // Path to use for profiler URLs RouteBasePath = "~/profiler",

     // Control which SQL formatter to use
     SqlFormatter = new StackExchange.Profiling.SqlFormatters.InlineFormatter(),
    
     // Control storage
     Storage = new MemoryCacheStorage(cache, TimeSpan.FromMinutes(60)),
    
     // To control which requests are profiled, use the Func<HttpRequest, bool> option:
     ShouldProfile = request => true,
    
     // Profiles are stored under a user ID, function to get it:
     //UserIdProvider =  request => MyGetUserIdFunction(request),
    

    });

  3. Configured the tag helper in my _ViewImports as per the sample

  4. Added the tag helper to my _Layout file, just before the close of the body tag:

<mini-profiler position="@RenderPosition.Left" max-traces="5" show-controls="true" start-hidden="false" />
  1. Made sure my controller produces some output for MiniProfiler:

    using (MiniProfiler.Current.Step("Example step")) { ... }

Despite all this, I get nothing. When I view source, I see that the tag helper has not produced any HTML.

like image 554
Matt Roberts Avatar asked Dec 12 '25 04:12

Matt Roberts


1 Answers

I'd added the tag helper to the wrong layout file.

like image 91
Matt Roberts Avatar answered Dec 13 '25 22:12

Matt Roberts



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!