我使用带有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:
protected void Application_BeginRequest(Object sender, EventArgs e)
{
if (Request.IsLocal)
{
MiniProfiler.Start();
}
}
protected void Application_EndRequest()
{
MiniProfiler.Stop(discardResults: false);
}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>
布局页面:
@using StackExchange.Profiling;
<head>
...
</head>
<body>
...
@MiniProfiler.RenderIncludes()
</body>登录页控制器:
using StackExchange.Profiling;
...
public ActionResult Landing()
{
var profiler = MiniProfiler.Current;
using (profiler.Step("Content Controller Landing"))
{
var user = ...;
return View(...);
}
}发布于 2019-06-18 19:40:14
这是我的答案MiniProfiler not showing up on asp.net MVC
结论,请确保在Application_Start()中添加了代码
protected void Application_Start()
{
...
MiniProfiler.Configure(new MiniProfilerOptions());//default setting
MiniProfilerEF6.Initialize();
}https://stackoverflow.com/questions/37574464
复制相似问题