Category Archives: .NET

Umbraco SurfaceController – Navigation

Currently, I work a lot with Umbraco. I am loving it a lot for a lot of good things (flexibility, possibility to go hard-core, good user experience, wonderful community). One part I was not 100% fond of is the macros part. Although macros (I mostly use MVC macros) are great in many respects, they quickly result in overcomplicated pieces of code with a very unhealthy mix of html and C# code.

One of those overcomplicating macros in my situation is the menu macro. Therefore, when the SurfaceController was ported from Umbraco 5 to Umbraco 4.10 (and above) I decided to rebuild my menu and breadcrumbs macros into a new navigation surface controller (called, how surprising, NavigationSurfaceController).

In this blog post, I will try to highlight some parts of the surface controller when I have some spare time to do so.

In the mean time, or when you are simply looking for all the code, feel free to download the source code zip. Don’t expect a working solution, just copy the files in your own solution (Umbraco extensions dll or even the main project) and start enjoying ;) . I would love to get feedback!

Happy coding!

Asynchronous JQuery loading using yepnope – almost there, but with quirks…

Today I stumpled upon a problem I was not (entirely) able to solve. I wanted to use the Javascript code printed below to load JQuery code asynchronously (using yepnope).

<script src="/scripts/modernizr-2.6.2.min.js" type="text/javascript"></script>
<script src="/scripts/yepnope.1.5.4-min.js" type="text/javascript"></script>
<script type="text/javascript">
	var docready = [], $ = function () { return { ready: function (fn) { docready.push(fn); } }; };
		load: '//ajax.googleapis<em><strong>OFFLINE</strong></em>.com/ajax/libs/jquery/1.8.2/jquery.min.js',
		complete: function () {
			if (!window.jQuery) {
				yepnope({ load: '/scripts/jquery-1.8.2.min.js', complete: initJQuery });
			} else {

	function initJQuery() {
		$ = window.jQuery;
		for (var index in docready) $(document).ready(docready[index]);

The code works almost perfectly. The JQuery library is loaded from the Google CDN as requested, and when that one is not available, it falls back to local script loading. While the JQuery library is not yet loaded, I hold all calls to $(document).ready() to fire them when JQuery is loaded entirely. This works! However, I discovered that JQuery plugins do not work with this code, as they require the JQuery or $ object.

I know I should use the initJQuery function for plugin loading based on JQuery, but since some plugins get inserted by ASP.NET partial views or Rejuicer, this is not possible. Currently, I stick with late loaded synchronous JQuery plugin loading while still holding $(document).ready calls for later (guaranteed) execution. I am curious about your solutions though ;) .

PS. Ow, currently, the piece of code I use for now, is:

// in head:
<script type="text/javascript">var docready = [], $ = function () { return { ready: function(fn) { docready.push(fn); } }; };</script>

// just before </body> tag:
<script src="//" type="text/javascript"></script>
<script type="text/javascript">window.jQuery || document.write('<script src="/scripts/jquery-1.8.2.min.js" type="text/javascript"><\/script>')</script>
<script type="text/javascript">
    // fire all preliminary $(document).ready(fn) calls immediately after jquery is loaded.
    $ = jQuery;
    for (n in docready) $(document).ready(docready[n]);

How to find public key token for a .NET DLL or assembly

I had to find the public key token for a strongly named assembly in .NET. Searching for a solution, I came along Wriju’s Blog. It appears the answer is very simple: use the .NET Framework tool ‘sn.exe’. Since I do not want to forget about this one, here it is:

  1. Open the Visual Studio <version reflecting DLL creator/signer> Command Prompt
  2. Point to the dll’s folder you want to get the public key
  3. Use the following command: sn –T myDLL.dll

This will give you the public key token. Of course this only works if the assembly is strongly signed :) .

ILMerge and .NET 4.0 projects – Unresolved assembly reference not allowed…

For plugin development on an ASP.NET website (using  MEF), I am trying to use ILMerge to merge all .NET assemblies in one assembly. I used a blog post from Scott Hanselman on ILMerge for a starter, but although I followed every step in his post, I ran into the following exception: Unresolved assembly reference not allowed: System.<WhatSoEver>. After  a little investigation, I discovered that ILMerge by default does not understand how to merge projects using the .NET 4.0 framework.

Adding an ILMerge.exe.config file with the following piece of code in it solved my problems:

  <startup useLegacyV2RuntimeActivationPolicy="true">
    <requiredRuntime safemode="true" imageVersion="v4.0.30319" version="v4.0.30319"/>

This was able to successfully resolve my issue.