Some people have asked me how BlogEngine.NET displays a dropdown list of countries when no source XML file is present. The simple answer is that you don’t need any external list to bind to from C#, you can instead use the CultureInfo class.

Consider that you have the following dropdown list declared in an ASP.NET page:

<asp:DropDownList runat="server" ID="ddlCountry" />

Then from code-behind, call this method which binds the countries alphabetically to the dropdown:

public void BindCountries()
  System.Collections.Specialized.StringDictionary dic = new System.Collections.Specialized.StringDictionary();
  System.Collections.Generic.List<string> col = new System.Collections.Generic.List<string>();

  foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.AllCultures & ~CultureTypes.NeutralCultures))
    RegionInfo ri = new RegionInfo(ci.LCID);
    if (!dic.ContainsKey(ri.EnglishName))
      dic.Add(ri.EnglishName, ri.TwoLetterISORegionName.ToLowerInvariant());

    if (!col.Contains(ri.EnglishName))


  ddlCountry.Items.Add(new ListItem("[Not specified]", ""));
  foreach (string key in col)
    ddlCountry.Items.Add(new ListItem(key, dic[key]));

  if (ddlCountry.SelectedIndex == 0 && Request.UserLanguages != null && Request.UserLanguages[0].Length == 5)
    ddlCountry.SelectedValue = Request.UserLanguages[0].Substring(3);

The method first adds all the countries from the CultureInfo class to a dictionary and then sorts it alphabetically. Last, it tries to retrieve the country of the browser so it can auto-select the visitors country. There might be a prettier way to sort a dictionary, but this one works.


Normally, I don’t dedicate an entire post to a remote link, but this is no normal case!

Douglas Crockford, whom I’ve never heard of before, did a speak recently at the 2007 FrontEnd Engineering Summit about code quality and the kind folk at Yahoo recorded it for everyone to see.

It’s a long video but it is worth watching it from start to finish. He has a huge insight into the history of software development and makes some really good analogies that help to understand what he talks about.

If you only watch one video this year, then this video should be the one.

Check out Douglas Crockford on code quality.


There seem to be some confusion about the Google Sitemap support of BlogEngine.NET, so I thought I would elaborate on it. First of all, BlogEngine.NET has a build-in sitemap handler so you don’t need to write it yourself.

BlogEngine.NET comes with many build-in handlers such as:

  • microsumary.axd
  • sitemap.axd
  • syndication.axd
  • commentfeed.axd
  • opensearch.axd
  • rsd.axd

…and more not so interesting ones.

All the handlers are accessible by typing http://www.yourblog.com/handler.axd where handler can be any one of them. So, in order to see the generated Google Sitemap just type in http://www.yourblog.com/sitemap.axd in your browser. Here is mine.

Auto discovery

You can tell Google manually about the location of your sitemap file or you can put the URL in the robots.txt file. I recommend putting it in the robots.txt because then Yahoo, MSN, Ask and Google can find it. Yahoo, MSN and Ask also supports the Google Sitemap format.

Just add this line to your robots.txt file:

sitemap: http://www.yourblog.com/sitemap.axd

This line can be the only line in the robots.txt if you don’t want to provide more information to the robots and spiders.

I hope this clears things up.


10 minutes ago we released the first version of BlogEngine.NET for anyone to download and use. This is very exciting to me because I’ve spent many hours during the last couple of months designing and coding in my spare time.

The release

We have been using CodePlex as a code repository and we also use it to host the release and help files. It has a nice discussion forum and issue tracker that has been used heavily by the beta testers. The repository is very impressive and it hooks directly into Visual Studio 2005 by a free download of Team Explorer. I can highly recommend it for anyone interested in starting an open source project.

Official website

The official website www.dotnetblogengine.net has also been released a couple of days ago and here you’ll find a lot of information, new themes and of course the team blog. The site is built 100% upon the BlogEngine.NET 1.0 release.


BlogEngine.NET was started out of the need for a simple ASP.NET 2.0 blog platform, that was easy to modify, extend and theme – a blog that didn’t needed an expensive SQL Server installation and was so simple that it didn’t needed 10 Visual Studio projects.

For six months I played with the idea, but it was first when I pitched it to Michal Talaga that it took off. We created the overall architecture and design, but not long after, Michal ran out of spare time and I was left alone with the project. Al Nyveldt came to the rescue, and soon also Brian Kuhn and Mauricio Quiros was part of the team and now things really got going.

After a month of high pace development, we came to realize that we needed help on the search algorithm so my co-worker Claus Christensen stepped up to the plate. Also the UI design of the admin section needed work, so Victor Rivero volunteered and designed the coolest looking admin section.

Today, the core team consists of Al, Brian, Mauricio and I with special thanks to Michal, Claus and Victor. That’s a very international team covering United States, Costa Rica, Spain, Poland and Denmark. Don’t get my started on the time zone issue :)

The project is only 2½ months old, but I have been running it on this website for two since the alpha release only 14 days after kick-off.


We look forward to keep the versions flowing at a steady pace and we already have a roadmap for the next 5 versions. The next version is planned for release already this summer.


Today, I had to print out all the .cs files in a Visual Studio project for code review. To my big surprise it wasn’t possible from within Visual Studio. It doesn’t even support multiple file printing. My only choice was to open and print the individual .cs files and print them separately. It’s just an unnecessary nuisance that could easily have been implemented by Microsoft.

All this made me think about how I write software and what the users of that software expect of it and how they use it. Normally, I have a pretty good idea about how my application is going to be used, but I always get surprised by the way it is actually being used by end users.

Things that the users would expect to find in an application should always be there. Otherwise, they get annoyed and maybe even frustrated. It’s extra work, but probably not that much.