This post originated from an RSS feed registered with .NET Buzz
by Scott Hanselman.
Original Post: A potential CAPTCHA Comment Spam Solution for dasBlog (and others) with no recompile or code changes
Feed Title: Scott Hanselman's ComputerZen.com
Feed URL: http://radio-weblogs.com/0106747/rss.xml
Feed Description: Scott Hanselman's ComputerZen.com is a .NET/WebServices/XML Weblog. I offer details of obscurities (internals of ASP.NET, WebServices, XML, etc) and best practices from real world scenarios.
I
took Jeff Atwood's CAPTCHA example
and added a new event called "UserValidationEvent"
Public Event UserValidationEvent As EventHandler
Then I raise the event at the VERY end of ValidateCaptcha I raise it:
RaiseEvent UserValidationEvent(Me, New EventArgs)
I made it a separate event because I want the CaptchaControl to integrate with my
blogging software WITHOUT any code on the server side. I didn't want to have
to recompile dasBlog or check anything in the Page_Load.
I made the appropriate web.config changes as per Jeff's instructions, and I added
the control to the CommentViewBox.ascx and put this code at the top:
protected void Page_Load(object sender, System.EventArgs
e)
{
//Ya, ya, I know I could have hooked this event up a number of ways
// including AutoEventWireUp but I like this fine, and it feels
// more explicit to moi.
CaptchaControl1.UserValidationEvent += new EventHandler(Foo);
}
</script>
There are a few Font issues to work out...he has it setup with a number of "no-no"
fonts, while I'd prefer a list of "allowed" fonts.