我正在尝试将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。任何人都可以建议吗?
哦。尴尬。
这是我的愚蠢错误。我将标签助手添加到了错误的布局文件中。
啧。