The past couple of days I’ve been working on migrating my blog from the Orchard CMS to MiniBlog. The main reason for me to migrate to a different system is because I don’t work a lot with Orchard anymore. There were also some crashes from time to time which I couldn’t explain.

I’m currently hosting my websites on Azure Websites, because of that I didn’t feel much for using a database system. SQL Azure is very nice of course, but it can also be quite expensive, especially if you don’t really need the features. The alternative is SQL Compact, but I’m not very keen on using this as well.

While searching for a database-less blogging system, I came across several solutions like Ghost, Jekyll and MiniBlog. All of these systems are slightly different and work with different techniques. The main reason I’m using MiniBlog as my new blogging engine is because it’s based on .NET. I could list all the cool features which are included, but as it’s already stated on the GitHub page, I won’t repeat it over here.

MiniBlog is a system which saves it’s posts in XML files. Therefore, I had to migrate all of my posts from the Orchard database to the files which MiniBlog understands. There’s already a project on GitHub called MiniBlogFormatter. This tool is able to export posts from DasBlog, BlogEngine.NET and WordPress to the MiniBlog format. I’ve used the code from this project as a basis for exporting my own Orchard posts.

It would have been cool if I was able to extend the MiniBlogFormatter project with my Orchard exporting code. There was however one caveat for this, I don’t know how to access the Orchard API from a remote application. I do know how to create modules, therefore I’ve created a module which was able to export the posts in the necessary format. If you want to know how to create an Orchard module yourself, there’s a post on this blog where I elaborate more on this.

The module itself isn’t fool-proof and user friendly (yet). It’s available on GitHub, so you can use it if you want or use it as inspiration for your own solution.

You can see I’ve created a new route so my own controller will be triggered.

new RouteDescriptor {
    Priority = 5,
    Route = new Route(
        new RouteValueDictionary {
                                    {"area", "JanVNL.Migrate"},
                                    {"controller", "Migrate"},
                                    {"action", "index"}
        new RouteValueDictionary {
                                    {"area", "JanVNL.Migrate"}
        new MvcRouteHandler())

The MigrateController will eventually hit the Initialize-method in the GetBlogPost class, which looks like this:

internal ICollection Initialize(bool redirect)
	var blog = Retriever.GetBlog(_blogService);
	var blogPosts = _blogPostService.Get(blog, VersionOptions.Published);
	_allBlogPosts = new List();
	string redirects = string.Empty;
	foreach (var blogPostPart in blogPosts)
		if (redirect) 
			string currentSlug = GetUrl(blogPostPart);
			string redirectRule = "<location path=\"{0}\"><system.webServer><httpRedirect enabled=\"true\" destination=\"{0}\" httpResponseStatus=\"Permanent\" /></system.webServer></location>";
			redirects = redirects + string.Format(redirectRule, currentSlug);
		else {

			var blogPost = new BlogPost();
			blogPost.Title = blogPostPart.Title;
			blogPost.Content = blogPostPart.Text;
			blogPost.PubDate = blogPostPart.PublishedUtc.Value;
			blogPost.LastModified = blogPostPart.PublishedUtc.Value;
			//blogPost.Categories = blogPostPart.;
			blogPost.Slug = GetUrl(blogPostPart);
			blogPost.Author = blogPostPart.Creator.UserName;
			blogPost.IsPublished = true;

			Storage.Save(blogPost, string.Format("C:\\BlogPosts\\{0}.xml", blogPost.Slug));
	return _allBlogPosts;

In this piece of code I’m iterating through all blog posts, converting them one by one to a BlogPost object and storing them using the Storage class. The BlogPost and Storage class are copied from the MiniBlogFormatter repository.

You probably also noticed the if-statement with the redirect variable. I’m using this variable to switch between saving the blog posts and generating a web.config block for adding the redirect rules. To retrieve the redirect rules, you have to set a breakpoint in the code and copy the contents of the redirects variable to the web.config. Not very user friendly, indeed.

This code worked for Orchard 1.7.2. I’m fairly sure it will also work on Orchard 1.5.x. and above. You can try it on other versions of course, most of the time you’ll get decent warnings or errors if something doesn’t work properly.

There are 2 ‘features’ in SharePoint (MOSS2007) which have kept me busy for quite some time in my last project. Yes, you’ve read it right the first time, my latest project was a MOSS 2007 web portal. Of course these issues aren’t really quirks as the product behaves by design, but it has kept me busy for more time as I would bargain for.

First quirk:

For some reason I had to create a console application to query the SharePoint user list and delete the users. Normally this doesn’t pose a problem at all. However, this time the following error was thrown every time:

The Web application at http://your-website-here:80 could not be found. 
Verify that you have typed the URL correctly. 
If the URL should be serving existing content, 
the system administrator may need to add a new request URL mapping to the intended application.

Quite strange, as the website does exist, I even double checked it.

After doing some research on the matter it turns out you need to specify the Platform target for your application. Mine was set to Any CPU and had to be changed to x86. After changing this specific option the code was running correct.


Second quirk:

The other thing I ran in to was not having permission to do anything on my site collection. We were using the stsadm export and stsadm import commands to move SharePoint site applications between environments.

This means I was familiar with setting the proper permissions on the web application and site collection. However, this time it didn’t work. After having spent several hours on this problem I finally noticed a feature which I had never seen before. Apparently you can set a site lock when doing an export on a website. This makes sense as you don’t want your data to change much when doing this.

However, after doing an import, you also need to remove the site lock. If you fail to do so, no one can make changes to the content of the website. To fix this, you can use the stsadm command, like so:

stsadm -o setsitelock -url http://your-website/ -lock none

The full documentation can be found on MSDN/Technet. You can also check the current site lock with the getsitelock operation.

Because I’m a developer who loves a GUI I’ve also found the option in Central Administration. Navigate to the Application Management tab and search for the Site collection quotas and locks.


On this page you can select your site collection and set the lock status for it.


After setting it to the status Not locked and you press OK, your site should be editable again.


Even though this post references some prehistoric software platform, I do hope you find it useful.

There are some cool features available in Linux. In an earlier post I already mentioned the apt-get functionality which is now also offered in Windows via Chocolatey. One of the other cool features is being able to execute something in the terminal as an Administrator by specifying sudo in the command.

Lucky for us Windows people, someone has created a tool which is able to do something similar as the Linux sudo-command. The tool is called Elevate and can be downloaded from over here:

After you have downloaded the zip-file from the website, copy the appropriate executable to your System32-folder and you are good to go!

By specifying the Elevate command in the command prompt, PowerShell window, Windows Search or Run-window the command will now be executed as an Administrator.




Depending on your UAC settings, you are still prompted with the question if you really want to run the application (Notepad) as an Administrator.

I think this functionality could be extremely useful if you want to run specific commands of a script as an Administrator.

Even though the Windows operating system is one of the best in my opinion, there are always something which is only available in a different OS. For example the apt-get functionality in Linux. I don’t know how this works exactly, but from my basic understanding it’s some kind of repository with a lot of software and libraries which you can download to your device by typing something like the following in a terminal window:

apt-get SomeSoftware

Why this feature isn’t available by default in Windows is a mystery to me.

Quite some time ago, Scott Hanselman blogged about Chocolatey. Chocolatey is something similar to the apt-get feature from Linux, but now available on a Windows machine. (disclaimer: it’s not really the same, but works for me)

Ever since reading this post I wanted to use this awesome piece of software, but all my systems were already up-to-date and never needed it. As of this week, I’ve started working on a new project. Therefore, a new virtual machine had to be installed and configured. An awesome excuse to start using Chocolatey!

With Chocolatey you can install all kinds of software, just by typing a command in your Command Prompt or PowerShell window. It will automatically download and install the software for you. The only thing you need to do is wait for the command to finish.

Installing Chocolatey is easy also, just open up a command prompt window and copy-paste the install text from the homepage to your window. After the installation has finished, the window will look something like this.


Now you are ready for the real fun, installing software via scipting!

Visual Studio 2010 was already installed on my development machine, so I had to think of something else which is necessary. My choice was ReSharper. If you are unfamiliar with the Chocolatey commands for installing this software, just head up to the website, search for the software in the search box and everything is explained as the search results show the exact commands you need to install the software.


Installing ReSharper can be done by just typing the following in the command prompt window:

cinst resharper

Hit [Enter] and wait.


When finished, the gods are thanked appropriately and the software is good to go.


Of course, you don’t want to install all your development software manually via the prompt window. Therefore, it’s also possible to script it!

I’ve created a small Install.ps1 and placed it in a DropBox folder, so I can use it everywhere. The contents look like this.

# Install Visual Studio 2012 Ultimate
cinst VisualStudio2012Ultimate
# Install Visual Studio 2012 Update 4
cinst VS2012.4
# Install Visual Studio 2013 Ultimate
cinst VisualStudio2013Ultimate
# Install ReSharper
cinst resharper
# Install Notepad++
cinst notepadplusplus
# Install Fiddler
cinst fiddler
# Install FileZilla
cinst filezilla
# Install SQL Server 2012 Express
cinst SqlServer2012Express
# Install KeePass
cinst keepass
# Install Spotify
cinst spotify
# Install GitHub for Windows
cinst githubforwindows
# Install VLC Player
cinst vlc
# Install Beyond Compare
cinst beyondcompare
# Install dotPeek
cinst dotPeek
# Install dotTrace
cinst dotTrace
# Install Remote Desktop Connection Manager
cinst rdcman
# Install Sublime Text 2
cinst sublimetext2
# Install PowerGUI
cinst PowerGUI
# Install TreeSize
cinst treesizefree
# Install DropBox
cinst dropbox
# Install Google Drive
cinst googledrive
# Install SkyDrive
cinst SkyDrive
# Install Google Chrome
cinst GoogleChrome
# Install Mozilla Firefox
cinst Firefox


There’s probably much more to Chocolatey, but this what I’ve figured out so far. It’s too bad not all software is supported for Chocolatey yet, but it’s a great start. Most software you need is already in the repository and you can add new packages yourself on the website.

For a project on the side I’m creating a Web API which has to parse XML requests in a POST. The first method I’ve written looks like this:

public HttpResponseMessage IndexPost(RequestModel requestMessage)
	return new HttpResponseMessage(HttpStatusCode.Accepted) { Content = new StringContent("This is the POST API response from BusinessPartner!") };

To test the new API I’m using the Postman Chrome plugin. With this plugin you are able to send requests to an endpoint and see what the response is. Of course you can also use Fiddler for this, but I like the user experience of Postman a bit more.

There were a few problems I encountered during the development of the Web API.

The first problem was this error:

    "message": "An error has occurred.",
    "exceptionMessage": "No MediaTypeFormatter is available to read an object of type 'RequestModel' from content with media type 'text/plain'.",
    "exceptionType": "System.InvalidOperationException",
    "stackTrace": "   at System.Net.Http.HttpContentExtensions.ReadAsAsync[T](HttpContent content, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger)\r\n   at System.Net.Http.HttpContentExtensions.ReadAsAsync(HttpContent content, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger)\r\n   at System.Web.Http.ModelBinding.FormatterParameterBinding.ReadContentAsync(HttpRequestMessage request, Type type, IEnumerable`1 formatters, IFormatterLogger formatterLogger)\r\n   at System.Web.Http.ModelBinding.FormatterParameterBinding.ExecuteBindingAsync(ModelMetadataProvider metadataProvider, HttpActionContext actionContext, CancellationToken cancellationToken)\r\n   at System.Web.Http.Tracing.Tracers.FormatterParameterBindingTracer.<>c__DisplayClass3.b__1()\r\n   at System.Web.Http.Tracing.ITraceWriterExtensions.TraceBeginEndAsync(ITraceWriter traceWriter, HttpRequestMessage request, String category, TraceLevel level, String operatorName, String operationName, Action`1 beginTrace, Func`1 execute, Action`1 endTrace, Action`1 errorTrace)\r\n   at System.Web.Http.Tracing.Tracers.FormatterParameterBindingTracer.ExecuteBindingAsync(ModelMetadataProvider metadataProvider, HttpActionContext actionContext, CancellationToken cancellationToken)\r\n   at System.Web.Http.Controllers.HttpActionBinding.<>c__DisplayClass1.b__0(HttpParameterBinding parameterBinder)\r\n   at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()\r\n   at System.Threading.Tasks.TaskHelpers.IterateImpl(IEnumerator`1 enumerator, CancellationToken cancellationToken)"

This was quite surprising as I thought I was sending a proper request which could be serialized. For reference, I was sending a POST request to http://localhost:11210/api/businesspartnerapi/ in this format:




As I couldn’t find anything on the internet explaining what I did wrong, I started looking through the options of Postman. Apparently you can add information to the header of the request, like a content type. After having added the contenttype text/xml to the message the API returned the response which I had expected.



Apparently you need to specify the correct content type in order for ASP.NET to know how to deserialize the object.

But there is more. The second problem I faced was the requestMessage being null.


Quite strange as the model is serializable. I’ve also added the [Serializable]-attribute to the model, but to no avail.

From the back in the WCF days I remembered you have to add the [DataContract]- and [DataMember]-attributes to a model if you to use them in services. Therefore I added them to my model.

The RequestModel now looks like this:

public class RequestModel
	public string RequestMessage { get; set; }

After POST-ing another request to the API I was able to see the result.


As you can see in the Watch window, the object is successfully created with the value I expected.

So, if you want to debug a Web API project, don’t forget to add the proper content type to your request and make sure you specify the attributes to your model so it can be (de)serialized.