BlogEngine.Net has been a great blogging solution for years. It is easy to install and upgrade, it is easy to configure, and you can be up and running with your own blog quickly. However, my frustration is comment spam. I have struggled with spam since my very first post. I look at professional bloggers, they have active comments, no catpcha, and no spam – I hate them. I have used the Commentor extension, and I have an Akismet account. I have talked to other users of BlogEngine.Net, and they have all turned off comments because spam is just an unacceptable problem with BlogEngine. I feel my blog needs comments. Otherwise, I can just post white papers on my web site. It’s decision time, get comment spam fixed, or get a new blog engine.
Earlier this year, the good folks at BlogEngine.Net released version 1.6. In this release, the BlogEngine.Net team has worked hard to address comment spam. Akismet and other spam controls have been integrated into the application. We’ll give 1.6 a try, and I will follow in a couple of weeks to see if the comment spam improves. Oh, and because life is just to easy, I’ll implement BE on .Net 4.0 in a subdirectory of my company web site (which is not yet on .Net 4.0).
All for 4, and 4 for all
The first issue with this upgrade is .Net 4.0. My hoster (discountASP.net) provides an instance of IIS, and the instance supports a single version of .Net. That means, if any application on the server is running .Net 4.0, they all need to run .Net 4.0. This requirement quickly spirals a quick upgrade into a 2-day project. The company web site and a series of supported UAT sites need to be upgraded. Most of these are MVC sites, so the upgrades are not traumatic, but testing takes some time. The bigger problem is convincing my customers that it is time to upgrade their sites to .Net 4.0 – which it is. But this posting is about a BlogEngine.Net upgrade not MVC upgrades. Just be aware that when you upgrade BlogEngine.Net to 4.0, you may need to upgrade other applications as well.
BlogEngine.Net Source
In all of my past installations/upgrades of BlogEngine.Net, I have simply used the executables. I use a customized theme, but I have no interest in customizing the core application. It works well, I (unfortunately) have had nothing of value to contribute to the BlogEngine.Net community, and I want future upgrades to go smoothly. This time I downloaded the BlogEngine.Net source in case I needed to do any customizations to help stop spam. The BlogEngine.Net source can be got here.
Opening the BlogEngine.Net solution in VisualStudio 2010 immediately opens the upgrade wizard. Quietly simply, no issues here. I stepped through the upgrade wizard, taking all defaults, and the solution upgraded without issues.
Merge your stuff
As I said previously, I typically upgrade the BlogEngine.Net application in place with new executables. If this is your plan, recommended if you do not anticipate customizations, there are posting that already outline steps by JRBlack and David Wynne. However, since I am compiling from source, I wanted to merge by posts and themes back from PROD to DEV. In this case, most of the APP_Data folder can be merged back, but not all. I copied my App_Data folder from PROD to a backup location on my local machine. I then merged App_Data/settings.xml entries using JRBlack’s post as a guide. The following list shows the entries that I needed to change. Also, make sure you retain any passwords in the settings.xml.
<commentsperpage>20</commentsperpage>
<moderationtype>1</moderationtype>
<numberofreferrerdays>1</numberofreferrerdays>
<mobiletheme>Mobile</mobiletheme>
<blogrollmaxlength>23</blogrollmaxlength>
<commentwhitelistcount>1</commentwhitelistcount>
<enableerrorlogging>False</enableerrorlogging>
<blogrollmaxlength>23</blogrollmaxlength>
<iscommentnestingenabled>True</iscommentnestingenabled>
<trustauthenticatedusers>True</trustauthenticatedusers>
<enablecommentsmoderation>True</enablecommentsmoderation>
To merge the remainder of the App_Data, I copied (from my PROD backup to my DEV source location) the files folder, the posts folder, the users.xml file and the roles.xml file. Also, if you have used Akismet in the past, save your url and Akismet key from your existing configuration. That’s it for the merge. Now to 4.0 it.
Upgrade
Some changes are needed to support .Net 4.0. First, the web.config file need some changes to <system.web><compilation> section. The referenced assemblies need to change to 4.0 assemblies.
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
To build the application as a .Net 4.0 application, change the project properties. Right click the BlogEngine.Core project in Solution Explorer, select Properties, and then go to the Application tab. In the Target Framework dropdown, select .Net Framework 4. Repeat the process for the BlogEngine.NET website, selecting Property Pages instead of Properties from the Solution Explorer context menu. In the Property Pages dialog, select the Build tab, and set the Target Framework to .Net Framework 4. That’s it. Build, run, enjoy – on DEV. Merging content and upgrading to .Net 4.0 was pretty straight forward.
Deploy
Most of the websites I build are .Net MVC sites. With MVC, the Package/Deploy settings are really straightforward and easy to use. BlogEngine.Net is a web application. Deployment takes a little more effort, and I am likely to disappoint you here. To deploy the web application, I added a web deployment project to the solution. Creating the deployment project was straightforward, and the result is a precompiled .zip file that can be copied to a hosting site. However, after deployment, I encountered errors associated with PrecompiledApp.config. I cleared that and had more errors. The BlogEngine.Net web site is relatively small, and web site deployment is outside the scope of this post. I simply copied the working DEV site to my PROD hosting facility. If web deployment projects are important to you, this strategy is heavily documented on the web including at MSDN and by Scott Gutherie.
I encountered another problem that I was not able to solve quickly, but a work around was easy. My deployment of BlogEngine.Net places BlogEngine.Net in a subfolder of a MVC application. This configuration has been no problem for previous versions, and it posed no problem for this version on my SQA site. However, on my PROD site, BlogEngine.Net (actually .Net) choked on not finding System.Web.Mvc even though BlogEngine.Net is not a MVC application. I could find no references to MVC in BlogEngine.Net. I believe the issue is due to my configuration. As a subdirectory under my MVC site (www.boxertech.com/blog), access to the blog application goes through MVC routing. The solution was simple. I placed System.Web.Mvc (version 2.0) in the BlogEngine.Net /bin directory. All is good, and if you are viewing this post, it still works.
Spam, Spam, Spam
The sole purpose of upgrading to BlogEngine 1.6 was to stop or at least control comment spam. BlogEngine.Net 1.6 integrates Akismet spam controls and has improved comment management. To configure the spam controls go to your blog settings, select the Extensions tab, and enable AkismetFilter. Once enabled, select Edit and enter and save your url and Akismet key. If you don’t have an Akismet key, you can get one here.
Next, go to the Comments tab of the blog Control Panel, and select the Configuration tab from the sub-menu. In the configuration, enable comments (that’s why we have a blog), and enable automatic moderation. That should be it. You can learn more about BlogEngine.Net Comment Management at the project web site.
Initial Feedback
I am not a Hanselman or Gutherie, so my level of comments may be embarrassing. However, it has been 2 days since I have upgraded to BlogEngine.Net 1.6, and I have some initial feedback. BlogEngine.Net and Akismet have correctly identified 8 comments as spam. One comment that was allowed, could possibly be spam based on the commenter's website, but the commenter’s email and comments appear to be legitimate. I will provide a short follow-up post in about 2 weeks to update the spam stats to see how well BlogEngine.Net does. Initial feedback appears good, and I have not had to resort to captcha – yet.
b15b3316-a5ea-4eeb-97ca-894d9345e20b|0|.0