【发布时间】:2017-06-08 11:46:29
【问题描述】:
我正在尝试将 MiniProfiler 插入到我的 ASP.NET Core MVC Web 应用程序中。我没有使用实体框架,我使用的是 Dapper。
按照sample app,以下是我的更改:
-
添加到
Startup.csConfigureServicesservices.AddMiniProfiler();
-
添加到
Startup.csConfigureapp.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),});
-
根据示例在我的
_ViewImports中配置标签助手 -
在我的
_Layout文件中添加了标签助手,就在body标签结束之前:
<mini-profiler position="@RenderPosition.Left" max-traces="5" show-controls="true" start-hidden="false" />
-
确保我的控制器为 MiniProfiler 生成一些输出:
使用 (MiniProfiler.Current.Step("示例步骤")) { ... }
尽管如此,我什么也得不到。查看源代码时,我看到标签助手没有生成任何 HTML。
【问题讨论】:
-
对于找到此内容的任何人,文档(包括入门)已在此处设置:miniprofiler.com/dotnet
标签: c# asp.net-core asp.net-core-mvc mvc-mini-profiler miniprofiler