How To Install Mini Profiler With EpiServer

Page load speed is an essential factor in any business web delivery plan. If a web page takes too long to load, site visitors will simply jump ship and go somewhere else. EpiServer comes with a few basic in-built tools that can help you refine your page load times, but, in my opinion, if you are really serious about performance you will need to use third-party tools specifically targeted towards performance. One tool I would recommend looking into is MiniProfiler.

How To Install Mini Profiler In EpiServer

Mini profiler can be installed via NuGet, in Visual Studio open your package explorer by right-clicking on your solution and selecting 'Manage NuGet Packages'. episerver_mini_profiler Type in 'Mini Profiler' and click install. Configuring Mini Profiler from here is pretty easy. Add the following code into your Global.ascx.
        protected void Application_BeginRequest()
        {
            MiniProfiler.Start();
        }
        
        protected void Application_EndRequest()
        {
            MiniProfiler.Stop();
        }
Add this into your web.config:
<handlers>
     <add name="MiniProfiler" path="mini-profiler-resources/*" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />
</handlers>
In your master layout, you will need to add this snippet of code:

@using StackExchange.Profiling;

@MiniProfiler.RenderIncludes()

Now when you try and run your website... episerver_mini_profiler_4 In the top left, you should see the mini=profiler tab available.

How To Measure Your Code

There are various ways you can architecture your performance monitoring code into solution. I would advise trying to follow the open/close principle and mix and match your monitoring and production code. When you architect your solution, if you use an IoC like structure map, you can keep this code separate. For the code you want to profile, you can use this code:
var profiler = MiniProfiler.Current;
using (profiler.Step("Stap Name"))
{
	// Do something
}


Jon D Jones

Software Architect, Programmer and Technologist Jon Jones is founder and CEO of London-based tech firm Digital Prompt. He has been working in the field for nearly a decade, specializing in new technologies and technical solution research in the web business. A passionate blogger by heart , speaker & consultant from England.. always on the hunt for the next challenge


Back to top
var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-35662136-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })();