gpt4 book ai didi

c# - MiniProfiler 没有出现在 ASP.NET Core 中

转载 作者:行者123 更新时间:2023-11-30 17:33:12 27 4
gpt4 key购买 nike

我正在尝试将 MiniProfiler 接入我的 ASP.NET Core MVC 网络应用程序。我没有使用 Entity Framework,我使用的是 Dapper。

sample app 之后,这是我的更改:

  1. 添加到 Startup.cs ConfigureServices

    services.AddMiniProfiler();

  2. 添加到 Startup.cs 配置

    app.UseMiniProfiler(新的 MiniProfilerOptions{//用于探查器 URL 的路径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. 根据示例在我的 _ViewImports 中配置标签助手

  4. 将标签助手添加到我的 _Layout 文件中,就在 body 标签结束之前:

<mini-profiler position="@RenderPosition.Left" max-traces="5" show-controls="true" start-hidden="false" />
  1. 确保我的 Controller 为 MiniProfiler 生成一些输出:

    使用(MiniProfiler.Current.Step(“示例步骤”)){ ... }

尽管如此,我还是一无所获。当我查看源代码时,我看到标签助手没有生成任何 HTML。

最佳答案

我将标签助手添加到了错误的布局文件中。

关于c# - MiniProfiler 没有出现在 ASP.NET Core 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44434904/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com