gpt4 book ai didi

asp.net-mvc - 无法使用 MiniProfiler 到达一垒

转载 作者:行者123 更新时间:2023-12-02 04:54:54 26 4
gpt4 key购买 nike

我已经阅读了我能找到的所有帖子并查看了一些教程,但还没有完成。

  1. 安装了 MiniProfiler MVC 和 EF6
  2. MiniProfilerEF6.Initialize(); 添加到 Global.asax Application_Start()
  3. 添加了 MiniProfiler.Start();到 Global.asax 中 protected void Application_BeginRequest() 方法。
  4. 将以下内容添加到我的 _Layout 页面

    <div class="row">
    @MiniProfiler.RenderIncludes()
    </div>
  5. 包装了我要分析的方法调用,因此:

    var profiler = MiniProfiler.Current;
    using (profiler.Step("Saving changes"))
    {
    eventId = _calendarRepository.AddUpdateCalendarEvent(eventDto);
    }
  6. 尽管我不需要这样做,但为了好的措施,将 MiniProfiler 处理程序添加到 web.config system.webserver 部分。

一切正常,但找不到 MiniProfiler。在 Chrome 和 IE 中试过,当我查看浏览器源代码时,我放置 @MiniProfiler.RenderIncludes() 的 div 是空的。

我正在尝试分析 dbContext.SaveChanges() 调用 - 我需要查看正在生成的 SQL EF。

谢谢

最佳答案

我在您的描述中没有看到任何关于针对个别请求启动 MiniProfiler 的内容。在 Global.asax 中会是这样的:

using StackExchange.Profiling;
...
protected void Application_BeginRequest()
{
if (Request.IsLocal || someOtherCriteriaForTurningOnMiniProfiler)
{
MiniProfiler.Start();
}
}

这是为任何个人请求运行 MiniProfiler 所必需的。

关于asp.net-mvc - 无法使用 MiniProfiler 到达一垒,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23900129/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com