【问题标题】:MiniProfiler not showing up in ASP.NET CoreMiniProfiler 未出现在 ASP.NET Core 中
【发布时间】:2017-06-08 11:46:29
【问题描述】:

我正在尝试将 MiniProfiler 插入到我的 ASP.NET Core MVC Web 应用程序中。我没有使用实体框架,我使用的是 Dapper。

按照sample app,以下是我的更改:

  1. 添加到Startup.csConfigureServices

    services.AddMiniProfiler();

  2. 添加到Startup.csConfigure

    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. 确保我的控制器为 MiniProfiler 生成一些输出:

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

尽管如此,我什么也得不到。查看源代码时,我看到标签助手没有生成任何 HTML。

【问题讨论】:

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


【解决方案1】:

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

【讨论】:

  • 对于其他发现此问题的人,将您 放入的布局文件会有所帮助...因为您可能不会是最后一个这样做的人事情:)
猜你喜欢
  • 2012-08-29
  • 2013-09-18
  • 2018-08-15
  • 1970-01-01
  • 1970-01-01
  • 2018-05-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多