Bootstrap FreeKB - MVC - Mini Profiler
MVC - Mini Profiler

Updated:   |  MVC articles

Install the mini profiler.

  1. In Visual Studio, select Tools > NuGet Package Manager > Package Manager Console.
  2. Type install-package miniprofiler and press enter.

 

Add the following to the global.asax file.

using StackExchange.Profiling;

protected void Application_BeginRequest()
{
    if (Request.IsLocal)
    {
        MiniProfiler.Start();
    }
}

protected void Application_EndRequest()
{
    MiniProfiler.Stop();
}

 

Add the following to the head of the _Layout.cshtml file.

@MvcMiniProfiler.MiniProfiler.RenderIncludes()

 

Add the following to the web.config file.

<system.webServer>
    <handlers>
      <add name="MiniProfiler" path="mini-profiler-resources/*" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />
    </handlers>

 

The source of the page should now have the following HTML:

<script async type="text/javascript" id="mini-profiler" src="/mini-profiler-resources/includes.js"...>

 

A small div should now appear near the upper left-hand corner of your site. Selecting the div will show details.

 

By default, the mini profiler will appear on your home page (www.freekb.net/Home/Index in this example), but will not appear on other pages. 

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter e313f4 in the box below so that we can be sure you are a human.