MiniProfiler没有出现在asp.net MVC上
我把它添加到我的Global.asax.cs:
protected void Application_BeginRequest() { if (Request.IsLocal) { MiniProfiler.Start(); } } protected void Application_EndRequest() { MiniProfiler.Stop(); }
我补充道
@MiniProfiler.RenderIncludes()
就在_Layout.cshtml中的标记下面。
在我的控制器中我正在使用:
public class HomeController : Controller { public ActionResult Index() { var profiler = MiniProfiler.Current; // it's ok if this is null using (profiler.Step("Set page title")) { ViewBag.Title = "Home Page"; } using (profiler.Step("Doing complex stuff")) { using (profiler.Step("Step A")) { // something more interesting here Thread.Sleep(100); } using (profiler.Step("Step B")) { // and here Thread.Sleep(250); } } return View("~/Views/Home/Index.cshtml"); } }
但我的页面上没有显示任何内容,也没有任何配置文件框。
在查看源代码时我只看到这个:
在您的web.config中,添加以下内容:
... ... ...
如果您想要一些甜蜜的MVC Action分析(与您的问题无关),请将此行添加到Global.asax.cs中的Application_Start
:
GlobalFilters.Filters.Add(new StackExchange.Profiling.MVCHelpers.ProfilingActionFilter());
如果有人尝试过Alden的解决方案并且仍然无法为你工作,请尝试将willardrostt建议的discardResults设置为false
// Global.asax.cs file protected void Application_BeginRequest() { if (Request.IsLocal) { MiniProfiler.Start(); } } protected void Application_EndRequest(object sender, EventArgs e) { MiniProfiler.Stop(discardResults: false); }