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-Profiler

Out 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:

umbraco_7_mini_profiler

The Easy Way

Ok.. 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!

umbraco_7_mini_profiler_query_string

Warnings

In 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.

Conclusion

In today’s guide, we’ve covered how you can get extra information out of Umbraco using Mini-Profiler. Mini profiler is useful for debugging macro errors, performance improvements etc… Out of the box Umbraco ships with the Min Profiler package so you will not need to install it.

To get it running simply add the debug=true flag in the web.config file and then use one of the methods above to enable it.

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

More Posts

2 replies

Trackbacks & Pingbacks

  1. […] and I suggest you start your search there.  You can find more information about that here, How To Debug Your Umbraco 7 Website. Fewer HTTP […]

  2. […] Mini-profiler to try and trace and profile what the current request is […]

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *