c# - MiniProfiler 不显示

标签 c# asp.net-mvc mvc-mini-profiler

我将 MiniProfiler v3.2.0.157 和 MiniProfiler.EF6 v3.0.11 与 C# 一起用于 ASP.NET MVC 4 网站。虽然我可以让分析器显示在网站的大部分页面上,但它不会显示在登录页面上。

我已经尝试了这里建议的所有方法: MiniProfiler not showing up on asp.net MVC 在这里:Using MiniProfiler with MVC 5 没有成功。

更新:我还尝试了此处描述的 donut 缓存技术: Donut hole caching - exclude MiniProfiler.RenderIncludes

我注意到对于正常工作的页面,如果 Application_BeginRequest 中的断点就在 MiniProfiler.Start() 上,MiniProfiler.Current 对我们大多数页面的请求都有一个值,但是对于我们的着陆页请求,此时它是空的。着陆页似乎没有任何会导致问题的特殊之处。

我的代码的重要部分如下所示。

Global.asax.cs:

protected void Application_BeginRequest(Object sender, EventArgs e)
    {
        if (Request.IsLocal)
        {
            MiniProfiler.Start();
        }


    }

protected void Application_EndRequest()
    {             

        MiniProfiler.Stop(discardResults: false);

    }

网络配置:

<system.webServer>
    <handlers>
      <add name="MiniProfiler" path="mini-profiler-resources/*" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />
    </handlers>
  </system.webServer>

布局页面:

@using StackExchange.Profiling;
<head>
    ...
</head>
<body>
    ...
    @MiniProfiler.RenderIncludes()
</body>

着陆页 Controller :

using StackExchange.Profiling;
...
public ActionResult Landing()
    {
        var profiler = MiniProfiler.Current;

        using (profiler.Step("Content Controller Landing"))
        {
            var user = ...;
            return View(...);
        }

    }

最佳答案

这是我的答案 MiniProfiler not showing up on asp.net MVC

结论,请确保您在 Application_Start() 中添加了代码

protected void Application_Start()
{
    ...
    MiniProfiler.Configure(new MiniProfilerOptions());//default setting
    MiniProfilerEF6.Initialize();
}

参见官方文档:https://miniprofiler.com/dotnet/AspDotNet

关于c# - MiniProfiler 不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37574464/

相关文章:

c# - 如何使用 roslyn 获得一种方法体的 il?

asp.net-mvc - Kendo UI 调度程序 : Custom view and edit behavior

c# - 使用 FIleUpload 处理程序后,IList<HttpPostedFileBase> 为空

c# - MiniProfiler ASP.NET Core - 基于用户角色的 ShouldProfile

http - 这行在 Firebug 中是什么意思?右手边蓝色字

c# - 如何彻底清除/设置WinRT 的RichEditBox 的文本?

c# - 为什么 Entity Framework 需要 30 秒来加载记录,而生成的查询只需要 1/2 秒?

c# - 没有通用扩展方法的类型推断

asp.net-mvc - 创建无需编码的 html 帮助程序

c# - MiniProfiler 没有出现在 asp.net MVC 上