36 Comments

As I wrote 10 days ago, a new BlogEngine.NET release had to be made to deal with some issues found in version 1.4. It’s exactly one month since the release of the 1.4 version and a lot has been fixed, tweaked and changed.

Besides some new cool features, more than 50 work items from the issue tracker at CodePlex have been implemented. That’s a lot of modified code and the result is significant. Here’s a list of some of the changes in version 1.4.5.

One of the exiting new things is that BlogEngine.NET now is released with SQL Server, MySQL, SQLite and VistaDB scripts and databases. That makes it really easy to choose the database that suits you best if you don’t want to go with the default XML provider. And by easy I mean as easy as copying a couple of files to the bin and App_Data folder and you’re all set to go.

I know some of you have had some issues with the 1.4 release, so I really hope you’ll enjoy this new version.

Download it now

0 Comments

Although it’s not more than three weeks since BlogEngine.NET 1.4 was released, we have no choice but to release a new version. There was a security issue which was fixed at made available for download and some huge edge case bugs as well. Also, the memory leak fix needed to be part of an official new release.

Fixes

Below are listed some major fixes and a description of what the problem was and who it effects.

The profile provider

If you we running in medium trust, the profile provider threw a security exception because medium trust doesn’t allow reflection. The ASP.NET build-in profile provider base class uses reflection, so we couldn’t just rewrite the feature without reflection. We had to totally recreate it without the ASP.NET profile provider model.

The widget framework

The medium trust issues continued in the widget framework, but only if you used the database provider. Again, this was due to the fact that medium trust environments doesn’t allow for reflection. Basically, we didn’t test the medium trust environment properly – if not at all – prior to release. The JavaScript that pops up the editor has also been tweaked so it now shows correctly in all browsers.

It wasn’t possible to write widgets that performs postbacks or client callbacks. It is now.

Create new user

When a new author was added they couldn't log in. This bug only figured in the XML membership provider when passwords where configured to be hashed in the web.config.

Broken links

In versions earlier than 1.4, the post links generated from a title could contain three hyphens in a row. In 1.4 it no longer did this because it made the URLs prettier and easier to read. However, it broke the old links from external sites. The upcoming release will also not generate URLs with three consecutive hyphens, but it will parse them correctly so no old links will break.

There are many other minor bugs that have been fixed.

New features

It’s not only bug fixes that made it into the upcoming release. Some new features have been added as well.

Filter by APML

As a semantic web freak, this is a feature I’m very proud to introduce to BlogEngine.NET. You can now filter the posts of a blog by your own APML file. An APML file is a prioritized list of your own interests represented in XML. All BlogEngine.NET 1.4+ users have such a file auto generated and it’s called /apml.axd. You only have to enter your blog URL and BlogEngine.NET will then find your APML using auto-discovery like the browser does for RSS feeds. Try it by clicking the APML filter link on the top right of this page.

File upload directories

Files and images uploaded will now be placed in new folders that are named by the year and month. This could be /files/2008/07/example.doc. This will make backup easier.

Use raw HTML editor by default

Some people don’t like the TinyMCE editor or any other editor and prefer to enter their own HTML. Now there is a switch that remembers your preferences and allows you to write your own HTML.

Force SSL in the MetaWeblog API

When you use Windows Live Writer or another editor through BlogEngine.NET’s MetaWeblog API you have always sent your username and password in clear text. This is the normal way that almost every blog platforms use. If you have a server certificate that allows you to run SSL, it is now possible to flip a switch that forces Windows Live Writer to send the data securely to your blog.

Other tweaks

  • Uncategorized posts are now shown in the archive
  • Calendar widget now works the first time it is added
  • Posting from Windows Live Writer now posts in the correct time zone
  • Users can now be edited again from the admin section
  • JavaScript removed from page and placed in blog.js for smaller page sizes
  • hCard microformat added to comments
  • HTTP compression of WebResource.axd (can be switched off)
  • Switch added to prefix post titles with blog name or not (SEO stuff)
  • Performance boost to CSS, image, file and JavaScript handlers by using 304 headers

I’m very sorry that this new release is necessary, because it is due to lack of a longer test phase. I do hope these new features will soften the fall a bit. Remember, if you are running the XML provider in full trust, then you might never have noticed any of the issues and might not need the upgrade. I do hope everybody will upgrade anyway, since it is a more stabile system with some new cool features. It's planned for download in a week.

0 Comments

My pride takes a hit every time I read the title of this post. At least it contains the word “fix”.

People have reported a memory leak on a few occasions, but I’ve never been able to find it and neither have anyone else. I just left it because it has never bothered me. It might be because of a very forgiving hosting partner that just adds more RAM if necessary and never tell me.

Yesterday evening I found myself in the right mood for tracking down this leak and it only took me 6 hours to find it. The fix took about 8 seconds, but what jolly 8 seconds that was.

The problem

After six hours I found that the leak was in the Related Posts server control. The constructor registered an event handler for the Post.Saved event, but the constructor wasn’t static like all the other controls. It was public which means that at every page view the event handler would be registered. That resulted in that the control never got disposed because of the reference to the event. So for each page view, an equal number of controls got stuck in memory and couldn't be garbage collected.

The fix

Make the constructor and event handler static so they only run once in the application life cycle. Let this be a lesson to all, remember to unhook your event handlers. The fix works for BlogEngine.NET 1.3, 1.3.1 and 1.4 and you just have to replace one file in the App_Code folder.

Download the memory leak fix at CodePlex and follow the instructions in the readme.txt.

I’m sorry it took so long to find this fix. I hope it hasn’t caused you too much trouble.

BlogEngine.NEXT

In the light of this and other bugs, we have decided to do a service release in a couple of weeks. Beside the memory leak fix, it will include many other tweaks, fixes and a few new minor features. It will be 100% backwards compatible with the current 1.4 release. If you have found some issues with 1.4 that you want fixed in the next release, please add them to the issue tracker.

0 Comments

The new BlogEngine.NET 1.4 let’s you easily create and distribute widgets like the ones you see on the right hand side on this page. Widgets are basically just small pieces of content and you can leverage the entire .NET Framework to create them. They can pull data from BlogEngine.NET itself or from external sources like web services or remote XML files. Everything is allowed and possible.

Create a widget

In this guide we will create a widget called Most comments and you can see it live on this site where it is called Hall of fame. The widget lists the people who have written most comments in the last x number of days.

 

You start by creating a new folder in the widgets folder. The name of the folder will be the name of the widget as well. In the new folder you have to add a user control called widget.ascx. If the widget contains settings that the blog owner should be able to change, then you have to add another user control called edit.ascx. It’s important that you name them exactly widget.ascx and edit.ascx.

 

Let’s start with widget.ascx. This is the user control that displays the widget content on the blog. The first thing you need to do is to change the inheritance of the code-behind file from System.Web.UI.UserControl to WidgetBase. Then you need to override two properties and one method.

The properties only have getters and they look like this.

///<summary>

///Gets the name. It must be exactly the same as the folder that contains the widget.

///</summary>

public override string Name

{

  get { return "Most comments"; }

}

 

///<summary>

///Gets wether or not the widget can be edited.

///<remarks>

///The only way a widget can be editable is by adding a edit.ascx file to the widget folder.

///</remarks>

///</summary>

public override bool IsEditable

{

  get { return true; }

}

The method to override is called LoadWidget and you should use it just as you would have used the Page_Load event handler. In other words, this is where you put all the code that needs to run when the widget loads every time a page is requested. If the widget can be edited then this is where you would retrieve the settings that BlogEngine.NET stores for each individual widget. The settings are stored in a simple StringDictionary.

StringDictionary settings = GetSettings();

The widget framework handles the caching of the settings, so you don’t have to worry about that.

Edit a widget

If the property IsEditable on the widget.ascx is set to True, the widget will render an edit link on the top right corner of the widget. When the edit link is clicked, an iframe popup shows up and loads the second user control edit.ascx. From there you can change the settings and save them.

The edit.ascx you create yourself doesn’t handle the title of the widget or whether or not the title show be shown. That is handled by the widget framework for you. The same goes for the save button.

You only have to add the controls needed to change what is specific to your new widget. In the case of the Most comments widget, it’s a checkbox and three text boxes. The first you need to do is to change the inheritance of the code-behind file from System.Web.UI.UserControl to WidgetEditBase. Next you have to override a method called Save, which get’s called by the widget framework when the save button is clicked. It saves the settings entered by the user.

public override void Save()

{

  StringDictionary settings = GetSettings();

  settings["avatarsize"] = txtSize.Text;

  settings["numberofvisitors"] = txtNumber.Text;

  settings["days"] = txtDays.Text;

  settings["showcomments"] = cbShowComments.Checked.ToString();

  SaveSettings(settings);

}

When you bind the settings to the controls, you have to use the Page_Load or similar methods just as you are used to. A good idea is to load the default values if the settings haven’t been set yet.

protected override void OnPreRender(EventArgs e)

{

  if (!Page.IsPostBack)

  {

    txtNumber.Text = "3";

    txtSize.Text = "50";

    txtDays.Text = "60";

    cbShowComments.Checked = true;

 

    StringDictionary settings = GetSettings();

    if (settings.ContainsKey("avatarsize"))

      txtSize.Text = settings["avatarsize"];

 

    if (settings.ContainsKey("numberofvisitors"))

      txtNumber.Text = settings["numberofvisitors"];

 

    if (settings.ContainsKey("days"))

      txtNumber.Text = settings["days"];

 

    if (settings.ContainsKey("showcomments"))

      cbShowComments.Checked = settings["showcomments"].Equals("true", StringComparison.OrdinalIgnoreCase);

  }

}

You have total freedom to create the edit page just as you like with JavaScript, stylesheets or whatever you like. It’s loaded asynchronously when the edit link is clicked and not before.

Download

Download the zip file below and extract the Most comments folder into your widget folder.

Most comments.zip (4,00 kb)

0 Comments

It’s been 6 months since the last release of BlogEngine.NET, but now the wait is over. You can download BlogEngine.NET 1.4 here.

What’s new?

A lot of new features and tweaks have been implemented in version 1.4. On top of all the tasks in the roadmap, more than 140 work items reported by the community made it. That’s a lot.

Here are some of my favourite new features:

  • Universal database provider (MySQL, SQL Server, VistaDB, Oracle etc.)
  • Drag ‘n drop widget framework (prototype video)
  • Author profiles using ASP.NET profile provider
  • Subcategories
  • Password encryption
  • Better performance
  • Tag selector in control panel
  • Semantic formats (FOAF, SIOC and APML)

You can read more about the new BlogEngine.NET 1.4 features at the official release note. If you wish to upgrade, then Al Nyveldt have written an excellent upgrade guide you should check out.

Next step

The next couple of weeks will be spent recording screencasts of the new features and give examples on how to write widgets. There's a lot of ground to cover with all the new features and possibilities for developers to utilize.

I hope you will enjoy this new version. It has taken a lot of hard work by the BlogEngine.NET team and I know they are very happy about the release - I know I am.