A 1-post collection

Akismet support for BlogEngine.NET 1.5

4 Oct 2009 Not sure why I didn't notice before, but the Commentor extension has been around for some time! It solves what I still needed, a place to manage all of the comments from a centralized location. The code below still adds spam management to individual comments and they may work together rather without incident.

Since I previously mentioned comment spam I've experimentally bolstered the defenses of this blog in my update to BlogEngine.NET 1.5, and… received the same spam. It's manually entered, and highly deceptive, frequently a "thanks, X helped me with Y" or just ever so subtly off-topic, often only the spam URL giving it away. At least this has absolved naive captcha of blame (still a little randomization in field names for playback bots might be a good idea).

So, BlogEngine.NET community, let's do something about the manual spam problem and integrate Akismet with a spam moderation queue like the WordPress plugin.

I've personally tackled it in my usual hackish fashion and converted BlogEngine's entire moderation queue into a spam queue (essentially moderation enabled but non-flagged spam is immediately approved). Who wants to have to moderate everything anyway?

The actual Akismet comment checking is accomplished with Joel Thom's ASP.NET API you may need to download.

Following that, here are the relevant comparison reports:

BlogEngine.Core 1.5 with Akismet

BlogEngine.Web 1.5 with Akismet

Joel.Net.Akismet.1.0.1 for BlogEngine.NET

Don't expect perfection, in particular my error handling is probably unduly sparse. I'm sure I'll notice it when it breaks painfully.

You will need a WordPress API key to work Akismet in the first place. Get one and specify it with your blog URL at the top of BlogEngine.Web\User controls\CommentView.ascx.cs.

Further you'll have to compile the changes to Core, update the dll in Web's bin, add a reference to Core in Joel.Net.Akismet, compile, copy dll assembly, and reference that from Web as well, but you already knew that because you're a programmer and the using references give it away anyway. Right? ;)

Or you could use this tidy package I've provided, keeping in mind to only replace files/assemblies you haven't modified from the stock download, and merge the rest. (If you've no interest in source code you may ignore the BlogEngine.Core and Joel.Net.Akismet.1.0.1 folders, the compiled assemblies are already in BlogEngine.Web.)

You must also Enable comment moderation.

Additional Details

  • Commenters are notified if their comment requires moderation immediately (the JavaScript now provides, very hackishly, an "isModerated" case).
  • Moderated comments have a new administrative Ham link for submitting false positives back to Akismet (this also approves the comment).
  • Approved (visible) comments have a new administrative Spam link for submitting false negatives back to Akismet (this also deletes the comment).
  • These links have been added to the corresponding admin comment notification emails as well.
  • Comment moderation has been toggled on in settings.xml (for XML data source blogs).
  • The Joel.Net.Akismet API has been modified to take the HttpRequest and BlogEngine.Core.Post directly.
  • Only labels.resx has been updated, this package is not localized (and could be a little cleaner for that), I'm but one English speaking man.

Please improve upon this, make it an extension (I don't think it can be 100%), or otherwise incorporate it into an official version.