4 Comments
  • 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

<recaptcha:RecaptchaControl
    ID="recaptcha"
    runat="server"
    PublicKey="your_public_key"
    PrivateKey="your_private_key"
    />

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)
{
   //LogVisit();
   recaptcha.Validate();
   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:

<recaptcha:RecaptchaControl
    ID="recaptcha"
    runat="server"
    PublicKey="my-public-key"
    PrivateKey="my-private-key"
    Theme="blackglass"
    />

 

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

Pin on pinterest Plus on Googleplus Post on LinkedIn

Comments

Comment by Pankaj

Hi
Can u plz help that when i put this control in my asp.net page then after postback it does not rerender in IE6 is there any solution?

Pankaj
Comment by Luiz

Very nice, I was trying to make recaptcha works with .net login component for so long... thank you!

PS: Sorry for the bad english

Luiz
Comment by Manny_Web

Thank you so much! I was looking for a walk through on how to add a ReCaptcha and this is perfect. Thanks again

Manny_Web