Edit Got the answer here
So I wanted to check out MiniProfiler to troubleshoot some performance issues. Before using it on production code I wanted to try it out with the a sample so went ahead with creating a MVC 5 application. This is plain vanilla app that gets created with the template.
Added this code in the Index() method of HomeController:
var profiler = MiniProfiler.Current;
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();
Added this line below the jquery bundle in _Layout:
@Scripts.Render("~/bundles/jquery")
@StackExchange.Profiling.MiniProfiler.RenderIncludes()
@Scripts.Render("~/bundles/bootstrap")
@RenderSection("scripts", required: false)
Ran the app. Nothing shows up. No profiling, nothing.
What am I missing?
Regards.
This is what I had to do to get MiniProfiler working in my ASP.NET MVC5 project:
Installed the MiniProfiler and MiniProfiler.MVC4 NuGet packages (the MVC4 package supports MVC5)
Add the following to
Application_Start()
in Global.asax:Add the following to 'Application_BeginRequest()' and 'Application_EndRequest()', also in Global.asax:
Add the following to _Layout.cshtml (just before the
</body>
tag):Add the following to the
<handlers>
section of Web.config:That was enough to profile each of the MVC Controller Actions and Views.
In my particular project I was using Entity Framework 6, so I also did the following:
a) Installed the MiniProfiler.EF6 package
b) Added the following to the end of
Application_Start()
in Global.asax:Also you have to add call:
In Global.asax.cs to Application_BeginRequest event.
And:
In Global.asax.cs to Application_EndRequest event.