asp.net-coreentity-framework-coremvc-mini-profilerminiprofiler

Getting "Not Found" error with mini profiler in ASP.NET Core with EF .net 5


I've added the following code to my asp.net core .net 5 app that works with entity framework. In startup.cs I have:

services.AddMiniProfiler(options =>
        {
            options.PopupRenderPosition = StackExchange.Profiling.RenderPosition.BottomLeft;
            options.PopupShowTimeWithChildren = true;
            options.RouteBasePath = "/profiler";
        }).AddEntityFramework();

and before my app.useRouting I have

app.UseMiniProfiler();

I added to a controller that I know gets called the following:

    using System.Collections.Generic;
    using System.Linq;
    using EFSvcc.Models;
    using Microsoft.AspNetCore.Mvc;
    using StackExchange.Profiling;

    namespace WebAppReactCRA.Controllers
    {
        [ApiController]
        [Route("[controller]")]
        public class WeatherForecastController : ControllerBase
        {
            private readonly svcodecampContext _dbContext;

            public WeatherForecastController(svcodecampContext dbContext)
            {
                _dbContext = dbContext;
            }


            [HttpGet]
            public List<DiscountCode> Get()
            {
                List<DiscountCode> discountCodes;
                using (MiniProfiler.Current.Step("WeatherForecastController: Groupby Clause For Total and Sent"))
                {
                    var z = _dbContext.DiscountCodes;
                    discountCodes = z.ToList();
                }

                return discountCodes;
            }
        }
    }

It's a SPA app so not surprised not to get the popup, but I can't seem to get http://localhost:5000/profiler to work. It just returns "not found"

Thoughts?


Solution

  • According to this:

    https://miniprofiler.com/dotnet/AspDotNetCore

    Based on your override of the RouteBasePath, your available routes are:

    http://localhost:{port number}/profiler/results-index
    http://localhost:{port number}/profiler/results
    http://localhost:{port number}/profiler/results?id={guid of specific profiler}
    

    I don't believe a route of just /profiler is actually exposed.