How to install BlogEngine.NET in a subdirectory06/29/2011
We’re a bit late to the game with the Dirigo Blog. We tend to not practice what we preach because we’re so busy doing work for others. Dr. Douglas C. Engelbart, an American inventor and early computer pioneer, said that the digital revolution is far more significant than the invention of writing or even of printing. This is so true for the blog. The 'little man', for the first time in recent history, truly has a platform for shaping the world. What unprecedented power! Bloggers and other contributors to user-generated content are behind Time magazine naming their 2006 person of the year as "you". As of December 2007, blog search engine Technorati was tracking more than 112 million blogs. Well, add one more to that huge number. Here we are.
I would be remiss to not remind our readers that blogging is but one component of an integrated website strategy. User generated content has a place – but, it does not, in my humble opinion, supersede the need for professionally developed content. Many Web 1.0 companies are performing quite well without a blog (not to mention Facebook, Twitter, MySpace, YouTub...). I always recommend building a solid base of content and budgeting resources to constantly add content (several new pages per month at a minimum) to the Web 1.0 side of a business before becoming snared in Web 2.0 techniques (ie: a blog).
The Dirigo Blog will function as a personal online repository for what our employees find interesting. Some posts will be highly technical and others will be pure commentary. My name is Payson Welch, a Dirigo Developer who spends a big chunk of my time developing blogs and social media. This first blog entry is devoted to BlogEngine.NET because our blog is [note: in 2010 we moved this blog to ADXStudio and again in 2013 we moved it to a Dirigo custom blog engine] designed with BlogEngine.NET. We're also actively using WordPress and WordPress MU with certain projects. BlogEngine.NET tends to be our prefered platform at the moment.
BlogEngine.NET is a free open source ASP.NET blogging platform. It comes standard with an XML based datastore but can also be configured to run from MS SQL Server. It is built to run as its own website. Integration into an existing website (our preferred method for optimum SEO) subdirectory can be tricky.
This post will explain how to integrate BlogEngine.NET into an existing website. This post assumes that you are running a fairly vanilla website and do not already have a roleProvider or membershipProvider already configured for your website. We will be installing onto a Windows 2003 Server with ASP.NET version 3.5 [note: this also works for Windows 2008R2 and .NET v4]. We are installing version of BlogEngine.NET version 1.5.
First we will create a new test website in IIS. Next we will put the blog in this website and move most of the files into ~/blog.
- Create a new website in IIS. Create a new test website in Visual Studio and push it to the server. Verify that the website resolves. I find it helpful to use my HOST file for DNS.
- Extract the BlogEngine.NET files into the website.
- If everything is setup correctly you should be able to visit the website and see the default BlogEngine.NET page.
- Attempt to visit /login.aspx and use the username and password admin / admin. You should now have an admin panel on the right hand nav.
- If you try to edit settings you will receive a read / write permissions exception. To fix this you need to give IIS read / write permissions on your App_Data directory.
- Create a new folder called “blog” or whatever you want to call it.
- Move all of the files from your default installation into the ‘blog’ folder EXCEPT these ones:
- Since you have now separated the website, some files will be trying to find other files that do not exist based on directory tree. The next step is to load the website in MS Visual Studio or MS Web Developer and to build the website. The most common errors are related to the /admin directory. For instance:
- /blog/admin/Extension Manager/Editor.ascx
- CodeFile attribute looks for “~/admin/Extension Manager/Editor.ascx.cs
- As you know the tilde ‘~’ character means to look at the root of the website. Since this file now lives in the ‘blog’ folder you must change the path to:“~/blog/admin/Extension Manager/Editor.ascx.cs
- Fix all errors of this type until the website compiles without errors.
- Find the appSetting key for “BlogEngine.VirtualPath” and change the value to “~/blog/”
- If you did everything correctly the website should now compile without error.
- Edit Web.Sitemap so that all of the paths are configured to work correctly with the blog subdirectory.
- You will also need to copy /App_GlobalResources in to the /blog directory since this is used by the admin pages. You will have errors if you do not copy this file.
- Delete /setup
- Your installation directory should now look like this:
If you are installing BlogEngine.NET into an existing website next you would merge the web.config files. To do this you would need to add all of the files in App_Code, App_Data, and bin folders. Next you would need to merge the web.config files. In order to do this, I usually open both [it helps that all Dirigo systems are dual screen – what a time saver]and piece by piece integrate the old website with the BEDN web.config and check after each integration to make sure the website still compiles. Most of the time, you have to merge all files before the site compiles. It depends on the site you are merging BogEngine.NET into. I highly recommend making backups in case you need to start fresh.
BlogEngine.NET is not perfect. Then again, it is better than many. We evaluated scads of blog software before selecting BlogEngine.NET in mid-2008. Each had strengths and weaknesses. BlogEngine.net has never failed to meet our needs. Here at Dirigo we’re installing one or two new installations per month. It sure would be nice if we only had to set the VirtualPath directive in order to get it to work in a subdirectory [hint to the development team].
The software is being actively developed. We recently upgraded some of our websites from version 1.3 to 1.5 and there were some nice enhancements. I found that it was much easier to import / export the data and that there was better support for MS SQL Server.
In my next post we will look at how to create an ASP.NET roleProvider, membershipProvider, how to upgrade your XML datastore to MS SQL Server and why it would be advantageous to do so.