微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用 EF .net 5 在 ASP.NET Core 中使用迷你分析器出现“未找到”错误

如何解决使用 EF .net 5 在 ASP.NET Core 中使用迷你分析器出现“未找到”错误

我已将以下代码添加到与实体框架一起使用的 asp.net core .net 5 应用程序中。在startup.cs中,我有

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

在我的 app.useRouting 之前我有

app.UseMiniProfiler();

添加一个控制器,我知道它被称为如下:

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

这是一个 SPA 应用程序,所以没有弹出窗口并不奇怪,但我似乎无法让 http://localhost:5000/profiler 工作。它只是返回“未找到”

想法?

解决方法

根据这个:

https://miniprofiler.com/dotnet/AspDotNetCore

根据您对 RouteBasePath 的覆盖,您的可用路线是:

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

我不相信只有 /profiler 的路由实际上是公开的。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。