How To Debug Your Umbraco 7 Website
None of us are perfect and when we start building a new website we will create bugs, make mistakes and do some very silly things at times. In today's guide, I'm going to cover some of the inbuilt tools available to you, as a developer, to make your life a little easier :)
Mini-ProfilerOut of the box Umbraco 7 comes with mini-profiler installed. Mini profiler is a Nuget package (more information available here) written by the guys at StackOverflow. As Mini Profiler is installed out of the box, in order to start using it with Umbraco, all we need to do is configure it correctly... simples :) When using mini-profiler, the first thing you should do is make sure that you have debugging enabled in your web.config, without that it will never appear. To do that, find the line that looks similar to this (around line 111) and makes sure the debug part is true.
<compilation defaultLanguage="c#" debug="true" batch="false" targetFramework="4.5">In production you will never want to deploy this, so I would recommend using web.config transforms using slow cheetah to get around the problem, more information about this can be found here. There are a few ways to show the mini-profiler on a page. The most primitive one is via code, in the razor view that you want the profiler to display, add the following code:
@using StackExchange.Profiling; @MiniProfiler.RenderIncludes()When you load your website, you should see a little red box in the top left-hand corner like so:
The Easy WayOk.. so the method above is the sure fire way of testing the mini-profiler is configured and works correctly. You may be thinking that adding all this code in your views isn't ideal and luckily there is an easier way to get it working. All you need to do is append '?umbdebug=true' to the end of your Url and magically the mini-profiler should appear!
WarningsIn previous versions of Umbraco you had to have an app setting, like this:
<add key="umbracoDebugMode" value="true" />This is NOT needed anymore. Another feature that is now obsolete is the use of one of the query string paramateres. Historically, by adding "?umbDebugShowTrace=true' to the end of any Url Mini-Profiler would show a stacktrace, again, this doesn't work anymore.