我将 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();
}
关于c# - MiniProfiler 不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37574464/