为什么我可能无法从MiniProfiler获得任何结果?

时间:2017-08-10 00:09:57

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

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

我可以看到XHR POST到/mini-profiler-resources/results返回404. chrome请求检查器为我提供了标准服务器404页面。

enter image description here

同一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

我在<handlers>的{​​{1}}部分中有以下项目,它位于正确的部分(例如this guy错误地将其放入ELMAH配置中)。

web.config

我已将所有输出缓存设置为 <add name="MiniProfiler" path="mini-profiler-resources/*" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" /> 秒。

我使用自定义1文件来测试自定义网址。

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

我还尝试将下面的代码段放入applicationhost.config而不是标准的web.config。

applicationhost.config

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

applicationhost.config

<section name="handlers" overrideModeDefault="Deny" />

我已将以下内容添加到application_start中:

<section name="handlers" overrideModeDefault="Allow" />

根据this answer的建议,我尝试卸载所有相关的软件包并按此顺序重新安装:

  • MiniProfiler
  • MiniProfiler.MVC4
  • MiniProfiler.EF6

更新

9天后,赏金到期,仍然没有快乐:(

如果将来有人读到这个想法/建议,我真的很想听听。 MiniProfiler是一个非常棒的工具,我很失望,因为我无法在这个场合工作。

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

1 个答案:

答案 0 :(得分:0)

遇到相同的问题后,我在这里找到了很好的答案。 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内的Web.Config中添加以下代码行服务器部分。

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