【问题标题】:Why might I not be getting any results from MiniProfiler?为什么我无法从 MiniProfiler 获得任何结果?
【发布时间】:2017-08-10 00:09:56
【问题描述】:

我似乎无法从MiniProfiler 获得任何结果。

我可以看到 XHR POST 到 /mini-profiler-resources/results 返回 404。chrome 请求检查器给了我一个标准的服务器 404 页面。

同一 URL 上的 GET 也返回 404,但有一条消息说“没有找到指定 id 的结果”(我确实在查询字符串中添加了 id)。

当我查看/mini-profiler-resources/results-index 时,它只会给我一个空表,其中包含字段标题 - 名称、开始、sql、持续时间等。

我已经尝试了一些方法 - 详情如下 - 在这个阶段,我不知道接下来可以尝试什么。任何调试此问题的指针或建议将不胜感激。


已安装的软件包:

  • MiniProfiler (v3.2.0.157)
  • MiniProfiler.EF6 (v3.0.11)
  • MiniProfiler.MVC4 (v3.0.11)

MVC4 也适用于 MVC5。这个项目是什么。


相关代码:

    protected void Application_Start()
    {
        MiniProfilerEF6.Initialize();
        MiniProfiler.Settings.Results_List_Authorize = IsUserAllowedToSeeMiniProfilerUI;
        MiniProfiler.Settings.MaxJsonResponseSize = int.MaxValue;
        Database.SetInitializer<ApplicationDbContext>(null);
        GlobalFilters.Filters.Add(new ProfilingActionFilter());
        var copy = ViewEngines.Engines.ToList();
        ViewEngines.Engines.Clear();
        foreach (var item in copy)
        {
            ViewEngines.Engines.Add(new ProfilingViewEngine(item));
        }
    }


    protected void Application_BeginRequest(Object source, EventArgs e)
    {
        if (Request.IsLocal)
        {
            // this IS being hit
            MiniProfiler.Start();
        }
    }


    protected void Applicaton_EndRequest()
    {
        MiniProfiler.Stop(discardResults: false);
    }


    private bool IsUserAllowedToSeeMiniProfilerUI(HttpRequest httpRequest)
    {
        return true;
    }

在 HomeController.cs 中:

[AllowAnonymous]
public ActionResult Index()
{
    var profiler = MiniProfiler.Current;
    using (profiler.Step("Doing complex stuff"))
    {
        using (profiler.Step("Step A"))
        {
            ViewBag.Title = "Home Page";
        }
        using (profiler.Step("Step B"))
        { 
            Thread.Sleep(250);
        }
    }

    return View();
}

在 MasterLayout.cshtml 中:

@using StackExchange.Profiling; 

... 

@MiniProfiler.RenderIncludes()

我试过了:

我已将discardResults 设置为false,如下所示:

    protected void Applicaton_EndRequest()
    {
        MiniProfiler.Stop(discardResults: false);
    }

我可以确认MiniProfiler.Start() 在页面加载时被点击。


我还可以确认找到了mini-profiler-resources/ 路由(使用Haack's Route Debugger


我在web.config&lt;handlers&gt; 部分中有以下项目,并且它在正确的部分中(例如,this guy 错误地将其放入 ELMAH 配置中)。

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

我已将所有输出缓存设置为 1 秒。


我使用自定义 applicationhost.config 文件来测试自定义 url。

我尝试删除自定义 url 绑定并仅使用标准 localhost:51347。

我还尝试将下面的 sn-p 放入 applicationhost.config 而不是标准的 web.config。

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

applicationhost.config我尝试改变

&lt;section name="handlers" overrideModeDefault="Deny" /&gt;

&lt;section name="handlers" overrideModeDefault="Allow" /&gt;


我在 application_start 中添加了以下内容:

MiniProfiler.Settings.MaxJsonResponseSize = int.MaxValue;


按照this answer的建议,我已经尝试卸载所有相关包并按此顺序重新安装:

  • 迷你分析器
  • MiniProfiler.MVC4
  • MiniProfiler.EF6

更新

9 天了,赏金到期了,仍然没有喜悦:(

如果将来有人阅读本文有想法/建议,我真的很想听听他们的意见。 MiniProfiler 是一个非常棒的工具,我很失望这次我无法让它工作。

如果我自己找到答案,我会发布它。

【问题讨论】:

  • 您使用什么查询技术?英孚?小巧玲珑?原始的 ASP.Net?还有什么?
  • 我使用的是 EF6.0
  • 您是否安装了 MiniProfiler.EF6 Nuget 包?
  • 是的,我已经安装了 MiniProfiler (v3.2.0.157)、MiniProfiler.EF6 (v3.0.11) 和 MiniProfiler.MVC4 (v3.0.11)。 MVC4 也适用于 MVC5。这个项目是什么。
  • 我猜你已经在Application_Start 中运行了MiniProfilerEF6.Initialize()

标签: asp.net-mvc mvc-mini-profiler


【解决方案1】:

遇到同样的问题后,我在这里找到了很好的答案。 http://www.mukeshkumar.net/articles/mvc/performance-test-with-miniprofiler-in-asp-net-mvc

如果在使用 MiniProfiler.Mvc4 或 MiniProfiler.Mvc3 运行应用程序后出现错误,并显示“/mini-profiler-resources/includes.js 404 not found”,那么只需在 Web.Config 内的 Web 中添加以下代码行服务器部分。

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

【讨论】:

  • 感谢您的回答。这是我尝试过的事情之一,但对我的情况没有帮助。
猜你喜欢
  • 2021-07-21
  • 2013-08-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多