The Artima Developer Community
Sponsored Link

.NET Buzz Forum
A potential CAPTCHA Comment Spam Solution for dasBlog (and others) with no recompile or code changes

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Scott Hanselman

Posts: 1031
Nickname: glucopilot
Registered: Aug, 2003

Scott Hanselman is the Chief Architect at Corillian Corporation and the Microsoft RD for Oregon.
A potential CAPTCHA Comment Spam Solution for dasBlog (and others) with no recompile or code changes Posted: Nov 12, 2004 4:14 AM
Reply to this message Reply

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.
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Scott Hanselman
Latest Posts From Scott Hanselman's ComputerZen.com

Advertisement

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:

<%@ Register TagPrefix="cc1" Namespace="WebControlCaptcha" Assembly="WebControlCaptcha" %>
<script Language="C#" Runat="Server">
  protected void Foo(object sender, System.EventArgs e)
  {
  if (Page.IsPostBack == true && CaptchaControl1.UserValidated == false)
   {
    Response.Redirect(Request.RawUrl);
   }
  }

  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. 

Read: A potential CAPTCHA Comment Spam Solution for dasBlog (and others) with no recompile or code changes

Topic: Web Services - The SCRAM Generation' Previous Topic   Next Topic Topic: Why does the BorCon Israel Registration page have to suck?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use