MiniProfiler没有出现在ASP.NET Core中

时间:2017-06-08 11:46:30

标签: c# asp.net-core asp.net-core-mvc mvc-mini-profiler miniprofiler

我试图将MiniProfiler投射到我的ASP.NET Core MVC Web应用程序中。我没有使用实体框架,我使用的是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。有人可以建议吗?

1 个答案:

答案 0 :(得分:1)

喔。尴尬。

这是我的愚蠢错误。我将标记帮助器添加到错误的布局文件中。

啧。

相关问题