MiniProfiler没有出现在ASP.NET Core中

问题描述 投票:2回答:1

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

sample app之后,以下是我的更改:

1)添加到Startup.cs ConfigureServices

services.AddMiniProfiler();

2)添加到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)根据样本在_ViewImports中配置标签助手

4)在_Layout标签关闭之前,将标签助手添加到我的body文件中:

<mini-profiler position="@RenderPosition.Left" max-traces="5" show-controls="true" start-hidden="false" />

5)确保我的控制器为MiniProfiler生成一些输出:

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

尽管如此,我什么都没得到。当我查看源代码时,我发现标记帮助程序没有生成任何HTML。任何人都可以建议吗?

c# asp.net-core asp.net-core-mvc mvc-mini-profiler miniprofiler
1个回答
1
投票

哦。尴尬。

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

啧。

© www.soinside.com 2019 - 2024. All rights reserved.