Implementing a naive captcha in BlogEngine.NET

30. January 2009

10-04-09 Keith Ratliff went to the very involved work of converting BlogEngine's comment submission process from JavaScript-centric to postback and standard ASP.NET validation, thereby enabling a more or less drag and drop installation of reCAPTCHA. Hooray Keith! Fantastic work. See that post instead.

A couple years ago Mad Kristensen implemented an invisible captcha into BlogEngine.NET, but as my blog has attested to, this is not enough.

Instead of inconveniencing readers with a captcha, you can use your own clever validation trick. The more unique it is, the less likely it will be automatically discovered and circumvented. When it is, you need a new trick.

A naive captcha is basically a captcha that's always the same image, and works off of the principle that you're site isn't important enough for spammers to manually specify (how cheerful!), but if it's good enough for Coding Horror it's good enough for me.

Of course being an image itself resists the automated discovery of this particular trick, and if it is discovered, manually or otherwise, it's easy to change the image (it need not even be of text).

Implementing my own naive captcha here has been quite effective so far. My next step may be Akismet for manually entered spam.

Implement your own

The patched (against vanilla BlogEngine.NET 1.4.5) files are available here. For making the change to your existing and customized blog, take a look at this comparison courtesy of Beyond Compare 3, or view the compact version below, this post needed some color.

You'll want to change the paths and formatting in CommentView.ascx to suit your liking, also the word "chicken".

Oh, and don't forget that my code sucks, sometimes intentionally even, because I'm lazy. Someone please be my guest and make this a properly coded BlogEngine.NET extension. Furthermore my first attempt was with the strictly-server-side RegularExpressionValidator control you see commented out below, which I couldn't get to work, so I used existing mechanisms instead.

Modified (check margin) lines are in red. Unimportant differences are in blue (mostly, the JavaScript isn't truly commented). The rest is context.

Comments

2009 October 7. 8:44 PM #

Spammer are everywhere in the internet and some unique way of preventing spammer=smart and simple and tough idea.It mean that how to make the spammer feel that it is hard to spam in this website and it is hard to find way to spam....If you are able to create that feeling to the spammer mean you win the game.....haha but that is not enough after stopping the spammer,you need to keep find more way to stop spammer in order to win them over and over again....Haha.......Will recommed this website tip for those people who hate spammer and want to win the game of battle over them...

manunited1991

2009 December 31. 11:41 PM #

Hi, can you please indicate necessary steps to follow to implement your code. I opened my blogengine web site with VS, replaced original files with yours, it compiles. Browsing the blog clicking on entry I get "Ooops! I can't find the page you're looking for" . It seems to me some object error somthing I am not doing correctly maybe not allowing pages to display

eliassal

2010 January 8. 8:39 AM #

@eliassal Hi there! :) I'd give a small pointer here or there if I could and thought it'd be helpful but I use reCAPTCHA (linked at the top) now thanks to Keith Ratliff's implementation. :) I suggest you try that. I also had to make my own tweaks that I should publish at some point here.

Christopher Galpin

2010 January 13. 12:03 AM #

Nice one

Rahul

2010 January 13. 12:39 AM #

Great stuff man!

Krishna

2010 January 24. 2:04 AM #

I wrote an article about how to implement a captcha solution on my blog:
www.codecapers.com/.../...ts-in-BlogEngineNET.aspx

Michael Ceranski

2010 January 24. 3:05 AM #

Nice Michael, thanks for sharing. I'll be posting my bug fixed slightly more complete version of Keith's soon here. :) Nice to have options.

Christopher Galpin

2010 March 8. 11:39 AM #

This is great....thanks

Peter

Add comment

*
(private)

biuquote
  • Comment
  • Preview
Loading




Powered by my custom BlogEngine.NET. Content © 2012 Christopher S. Galpin