首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MiniProfiler不显示

MiniProfiler不显示
EN

Stack Overflow用户
提问于 2016-06-02 00:46:12
回答 1查看 1.7K关注 0票数 2

我使用带有C#的MiniProfiler v3.2.0.157和MiniProfiler.EF6 v3.0.11用于ASP.NET MVC4网站。虽然我可以让分析器显示在网站上的大多数页面上,但它没有显示在登录页面上。

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

更新:我还尝试了这里描述的甜甜圈缓存技术:Donut hole caching - exclude MiniProfiler.RenderIncludes

我注意到,对于工作正常的页面,如果MiniProfiler.Start()上的Application_BeginRequest中存在断点,MiniProfiler.Current会为我们大多数页面的请求提供一个值,但在请求登录页面的情况下,它在这一点上为空。登录页似乎没有什么特别的地方会引起问题。

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

Global.asax.cs:

代码语言:javascript
复制
protected void Application_BeginRequest(Object sender, EventArgs e)
    {
        if (Request.IsLocal)
        {
            MiniProfiler.Start();
        }


    }

protected void Application_EndRequest()
    {             

        MiniProfiler.Stop(discardResults: false);

    }

Web.config:

代码语言:javascript
复制
<system.webServer>
    <handlers>
      <add name="MiniProfiler" path="mini-profiler-resources/*" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />
    </handlers>
  </system.webServer>

布局页面:

代码语言:javascript
复制
@using StackExchange.Profiling;
<head>
    ...
</head>
<body>
    ...
    @MiniProfiler.RenderIncludes()
</body>

登录页控制器:

代码语言:javascript
复制
using StackExchange.Profiling;
...
public ActionResult Landing()
    {
        var profiler = MiniProfiler.Current;

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

    }
EN

回答 1

Stack Overflow用户

发布于 2019-06-18 19:40:14

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

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

代码语言:javascript
复制
protected void Application_Start()
{
    ...
    MiniProfiler.Configure(new MiniProfilerOptions());//default setting
    MiniProfilerEF6.Initialize();
}

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37574464

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档