Blog has moved to

My blog has moved to In addition, I’m no longer running on WordPress, You can read about how I’m using Wintersmith, NodeJS and hosting on GitHub Pages on the new blog.


Using Git-Tf: Suppress the TFS warning when loading a solution

You’ve started using Git-TF?   ….Yes

But now you’re annoyed when opening the solution in Visual Studio, because TFS informs you it can’t find a mapping and asks you if you want to temporarily open the project or remove source control bindings? …Yes

You’re tempted to remove source control bindings? …Yes

But that wouldn’t be appreciated by the other developers on your team. So, let’s make that dialog disappear without removing source control bindings.

These instructions work for Visual Studio 2010/TFS 2010. All bets are off for other versions.

Step 1 – Install TFS Powertools

Download TFS Powertools from Visual Studio Gallery and install.

Step 2 – Bring up TFS Connection dialog

Open command prompt and run “tfpt connections“. See screenshot.

Step 3 – Find TFS project you are working in and click ‘Edit…’

In the screenshot below, the top-level items in the tree control (redacted in black) is the TFS server and the second-level items in the tree control (redacted in red) is the project on the TFS server. Click on the related project and then click the ‘Edit…‘ button.

Step 4 – Mark the Server Offline

You must check the ‘Server is offline’ checkbox. See screenshot.

Note: You must check the ‘Server is offline’ checkbox, my screenshot only shows it unchecked, so you know what the dialog will look like when you bring it up.

Step 5 – Enjoy

You will no longer be bothered with dialogs asking if you want to remove source control bindings when you open the solution in Visual Studio.

You will still be able to use the Team Explorer.

Using media in Umbraco without dragging down performance

Is your page rendering slow in Umbraco? Are you using Umbraco media in that page? Well, you’re probably doing it the slow way. To be fair, the fast way isn’t necessarily obvious.

Are you doing using umbraco.library.GetMedia? It caches the media result in the ASP.Net cache, making it fast. Any other function you might use for media will always queries the database.

You might ask, why is it so much slower than everything else in my page, isn’t Umbraco querying the database for my page content? No, Umbraco isn’t querying your database for content, it’s using an cache of all your content that it stores in a xml file. Umbraco only queries the database for content when it absolutely has to. But, it always queries the database for media, unless you use umbraco.library.GetMedia.

umbraco.library.GetMedia returns an XPathNodeIterator which can make it difficult to work with. I’ve written a helper function to return the url that can be used in an img tag. Expect significant speeds up in rendering by using umbraco.library.GetMedia.

@using System.Xml.XPath;
namespace MyProject {
  public class Helper {
    public static string GetImageUrlFromUmbraco(string mediaId) {
      XPathNodeIterator iter = umbraco.library.GetMedia(Int32.Parse(mediaId),
      if (iter == null) return string.Empty;
      //umbraco caches XPathNodeIterator, so make copy
      //since MoveNext() will mutate it.
      iter = iter.Clone();
      XPathNavigator fileNode = null;
      if (iter.MoveNext()) {
        fileNode = iter.Current.SelectSingleNode("//umbracoFile");
      return (fileNode != null ? fileNode.Value : string.Empty);

Here is an example of using that function in a Umbraco razor macro for a document type called “MyPage” with a property called “logo” with a type of “Media Picker”.

@using MyProject;

var mypage = @Model.AncestorOrSelf("MyPage");
<img src='@Helper.GetImageUrlFromUmbraco(@mypage.GetProperty("logo").Value)' />

Investigating page performance in Umbraco 4

Well, remember when dealing with performance, you should always use metrics, not your intuition. Repeat after me, metrics, not intuition. So, how do we do that in Umbraco?

Umbraco makes this easy, simply add umbDebugShowTrace=true as a url parameter to your page. This enables ASP.NET page level tracing for that page and Umbraco also liberally writes to the Trace object. The trace results will be rendered into the page, see below.

Or you can use /Trace.axd , built-in to ASP.NET to view the trace results, see below.

That didn’t work?

1) Make sure you have umbDebug set to true in the Web.config. When deploying to production this needs to be false.

  <add key="umbracoDebugMode" value="true" />

2) Make sure you have tracing turned on in the Web.config. When deploying to production, this needs to be false.

  <trace enabled="true" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true" />