•   Posted in: 
  • C#

A quick and good solution to add Captcha’s to your solution is to use Google’s. There are various solutions available online to make your own captcha, but I prefer using Google’s Recaptcha which can be found on: http://www.google.com/recaptcha

There is this free usercontrol available online.

Here are the 10 easy steps to follow:

1) sign up at https://www.google.com/recaptcha/admin/create

2) add a site

3) copy & paste your public and private key in notepad as reminder

4) download and extract the latest version of the .net control which can be found at http://code.google.com/p/recaptcha/downloads/list?q=label:aspnetlib-Latest

5) put the extracted files in the Bin folder of your solution

6) The next thing is to add a reference in your project to the DLL in your Bin folder. [more]

7) Register the control in the page (or usercontrol) by adding this to the top of the page:

<%@ Register TagPrefix="recaptcha" Namespace="Recaptcha" Assembly="Recaptcha" %>

8) Insert the control in your aspx (or ascx) file at the right place


9) Insert your public and private key which you stored with notepad.

10) Do not forget to validate the Recaptcha control. Here is how I did it in my code behind of an <asp:login control:

protected void Login1_LoggedIn(object sender, EventArgs e)
   if (recaptcha.IsValid)
   { // etc

There is more info about this matter available online at http://code.google.com/intl/nl/apis/recaptcha/docs/aspnet.html

You can customize the look and feel of the Recaptcha control with CSS or by using the predefined theme’s, more about that can be found here http://code.google.com/intl/nl/apis/recaptcha/docs/customization.html

I used the blackglass theme like this:



Good luck!

Let me know in the comments if you had any troubles with following the above 10 step plan.

kick it on DotNetKicks.com Shout it

Post on LinkedIn