[eng] BlogEngine multibloging made easy!

While I was on New Zealand last year, I wondered what I would take to make a BlogEnginge "multiblog" application. I spoke to Mads about the issue, hoping he had already been implementing that feature somewhere under the covers of BE, but unfortuneatly I came to early.

He told me that one of the developers on the famouse piece of software actually was working on such a feature, but only in his sparetime. So I contacted the developer for more details. His name is Roman D. Clarkson and has been working on BE for quite some time. Roman told me about his implementation and I went off, trying to run and test it, all while he was developing it. Hours, days and weeks went by. Eventually I realised that my issue was bigger than I had first expected, and all of a sudden I felt like one of those customers that order a feature but doesn't realize how much time it will take. Doooh!

The multiblog application came to my mind when I was preparing ActiveDeveloper.dk for handling more blogs. I felt crippled because I had to log on to the server, configure a virtual directory and move files each time a new blog had to be created. Booooring work!

I didn't want to change the blogging platform to something else, because I believe in supporting a local project, and because there is no blogging software that is as good as BlogEngine.

On Friday night I had been over at ZYB to drink a cold beer with Mads. The guys over there are seriously having fun!!! We didn't talk about the multiblog feature at all, because the application left my mind months ago. Instead we talked about who is going to TechEd EMEA and who we would like to meet down there.

I left ZYB early and went home to watch a movie. I accidently turned on my computer while sitting in my couch and thought "ohh well, I guess I could fire up Visual Studio and build something". So I did.

A couple of days ago I had fallen in love with the IIS 7 API, so the first thing I did was to include the Microsoft.Web.Administration.dll file in the new project. But I also have a lot of love for BlogEngine. All of the sudden I realised that my "multiblog" application could become true, or at least kind of 🙂

I added a IIS web site called MultiBlogs and applied my desired configuration to it.


I configured the config directory under "%SystemDir%\Windows\System32\inetsrv\config" and had to add the IIS_USERS to the user list and give it sufficient rights.


If you want to read or write to the files withn the config folder, from a website, you need to add this group.

Then I downloaded the lateset version of BlogEngine and created a directory where I copied a all the BlogEngine files into. I named this directory "BlogFiles".


So now I was ready to get "code cracker lacking". So I opened up the MultiBlogs website from Visual Studio.

I created a simple page where I added a few controls.

<form id="form1" runat="server">
    What is my name ?
    <asp:TextBox ID="tbBlogName" runat="server" />
    <asp:RequiredFieldValidator ID="rfvBlogName" ControlToValidate="tbBlogName" ErrorMessage="*"
        runat="server" />
    <asp:Button ID="Button1" Text="Fyyyyr" runat="server" OnClick="Unnamed1_Click" />
    <br />
    <asp:Label ID="lblMessage" runat="server" />

I added 2 simple classes in my App_Code directory. BlogInstaller.cs and IISHandler.cs.

I wanted to use the BlogInstaller class for creating the new blog directory on the disk, but also for the copying of files. The files that should be copied from the "BlogFiles" directory into the new directory. So 2 methods and a construtor - easy money!

IISHandler.cs, I would this for 2 things as well. Check if an application already exists in the "MultiBlogs" website, but it would also be the creator for both an application and a virtual directory for the new blog on the IIS.

The code file for the aspx page ended up looking like this.

private const string IISSiteDirectoryPath = @"C:\WebSites\MultiBlogs\";
private const string BlogCleanInstallDirectoryPath = @"C:\WebSites\BlogFiles\BlogEngine.Web\";
private const string ApplicationPoolName = "MultiBlogs";

protected void Unnamed1_Click( object sender, EventArgs e )
    if( Page.IsValid ) {
        string blogName = tbBlogName.Text;

        foreach( var item in VirtualDirectoryCollection.InvalidVirtualDirectoryPathCharacters() ) {
            if( blogName.Contains( item ) ) {
                lblMessage.Text = String.Concat( item, " is not allowed!" );

        if( !IISHandler.ApplicationExists( IISSiteDirectoryPath, blogName, ApplicationPoolName ) ) {
            BlogInstaller installer = new BlogInstaller( String.Concat( IISSiteDirectoryPath, blogName ), new DirectoryInfo( BlogCleanInstallDirectoryPath ), new DirectoryInfo( IISSiteDirectoryPath + blogName ) );
            IISHandler.CreateVirtualDirectory( IISSiteDirectoryPath, blogName, ApplicationPoolName );

            lblMessage.Text = "Created!";
        } else {
            lblMessage.Text = "Exists!";

Now, it is possible for me to create blogs on the fly. Now I only need a site where I can install it...dohhhh!

Download the sourcecode here.

Comments (21)
  1. qthangit says:

    Can I configure MultiBlog (BlogEngine) on IIS 6?

    I can’t upgare from IIS 6 to IIS 7

  2. qthangit says:

    I want to have multi blog on single database. anybody can help me!

    Thank you very very much!

  3. malvarez says:

    Please Daniel …

    I also am of the club of:

    "Can I configure MultiBlog (BlogEngine) on IIS 6? "

    "I can’t upgare from IIS 6 to IIS 7"

    do you know like doing it?

    Thanks …

  4. Garry Trinder says:

    Guys, look at http://vadstup.dk for IIS 6 version 🙂

  5. Yanga says:

    The correct link for the IIS 6 version : http://www.vadstrup.dk

  6. qthangit says:

    I have deployed successful!

    I still have a bit worry about this way! I like the way that the same database for multi blogs. I will wait for that way

    Thank you very much

  7. BJ Knudson says:


    For some reason this code copies the files, but crashes on this line;

    application.ApplicationPoolName = serverManager.ApplicationPools[ applicationPoolName ].Name;

    With a NullReferenceException.  It suggests to use the "new" keyword to create an instance of the object.  I’m not sure what I’m doing wrong.  

    Visual Studio 2008

  8. Tommy Boy says:

    Great work man.  If these dudes can make multi-blogs centralized in the API without requiring this IIS workaround, it would be immense for our projects.

  9. Fraga says:

    I have problems, giving the right permision to the App_Data, with iis 6, I guess because there is no

    C:WINDOWSsystem32inetsrvconfig folder.

  10. Interesting, but maybe this could be done more securely so you do not have to give the web site write access to your configuration. What I would do is run a .NET Windows Service that you web site can talk with over WCF. Then I would run that Windows Service as a user that is granted specific access to the IIS configuration. That way you do not have to open up access to the entire web site and you can have the Windows Service only talk on localhost so it is much more secure.

    Still I would like a way to not replace all of those files. A little URL mapping and some changes to BE and you may have that solution as well.

    You use of the Microsoft.Web.Administration.dll assembly is interesting. I will have to look into what I can do with that.

  11. Good concept, though I couldn’t make it work on IIS 6. Keep crashing with null reference exception.

  12. Good concept, though I couldn’t make it work on IIS 6. Keep crashing with null reference exception.

  13. Just wanna say thank you for welcoming me in your website and also for the information that you have included in this website.

    Hope that this will not be the last post that I could be read written by you webmaster! Thanks for this useful information. Have a nice day webmaster!

  14. Just wanna say thank you for the information that you have been shared. You created a blog that really suits to my taste.

  15. IPO says:

    Thanks for the information that was helpful for me.

  16. Grant GRiffith says:

    Am trying to get the multiblog working and keep getting an error when it is asked to create a new one.  Does this still work on the newest version? 1.5

    Here is the error I am getting… Maybe something simple I missed???

    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

    Source Error:

    Line 39: Site site = serverManager.Sites[ applicationPoolName ];

    Line 40:

    Line 41: var a = ( from v in site.Applications

    Line 42:  where v.Path.Replace( "/", String.Empty ) == applicationName

    Line 43:  select v ).DefaultIfEmpty();

    Source File: f:clientsyada.commultiblogsApp_CodeIISHandler.cs    Line: 41

  17. Andrew says:

    Wow, I really need something like this.  Multiblogging is awesome for SEO purposes…eh….hummm.  If you know what I mean 🙂

  18. Angelo says:

    The problem i have with these things is that the technology moves too fast these days, the learning curve for a new resource coming into a project can be a drag for the others.  Needless to say, I like the BlogNet Engine otherwise I would not bother being here.

    I will download and install RC 2.0 and see what it looks like, maybe I can add a little value to it somehow, but the big thing for me is that it stays on IIS platform, I am tired of PHP MySQL and APACHE to be quite honest.

  19. Jack says:

    Thanks for this valuable post. I just want to let you know that I just check out your site and and you rock!. I'm looking forward to read lots more of your articles… You got it covered buddy. http://wiredtreereview.org/

  20. شات صوتي says:

    know that I just check out your site and and you

    <p><span lang="ar-sa"><a href="voice.t-jnn.com/">%D8%B4%D8%A7%D8%AA صوتي</a> ,

Comments are closed.

Skip to main content