【发布时间】: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 的<handlers> 部分中有以下项目,并且它在正确的部分中(例如,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我尝试改变
<section name="handlers" overrideModeDefault="Deny" />
到
<section name="handlers" overrideModeDefault="Allow" />
我在 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