Click here to Skip to main content
12,552,460 members (43,030 online)
Click here to Skip to main content
Add your own
alternative version


31 bookmarked

Google ReCaptcha 2.0 - Control

, 8 Mar 2015 CPOL
Rate this:
Please Sign up or sign in to vote.
.Net control/wrapper for the Google NEW ReCaptcha API 2.0


This article provides a solution to integrate NEW Google Captcha control easily into application. Here is the screen cap of new ReCaptcha:


The solution is based on the Google API docs i.e. It uses the automatic way of rendering Google reCaptcha on the page.

Using the code

Download the attached DLL file i.e. "GoogleReCaptcha.dll" and reference it to any project. Then, add reference to this ReCaptcha control on page where you want to display Captcha control.

For example:

<%@ Register Assembly="GoogleReCaptcha" Namespace="GoogleReCaptcha" TagPrefix="cc1" %>

Then, you can use the control wherever you want to use this control like given below:

<cc1:GoogleReCaptcha ID="ctrlGoogleReCaptcha" runat="server" PublicKey="YOUR_SITE_KEY" PrivateKey="YOUR_SECRET_KEY" />

The public and private keys for captcha can be taken from Google i.e. The GoogleReCaptcha control can also be added dynamically onto the page using code below:

GoogleReCaptcha.GoogleReCaptcha ctrlGoogleReCaptcha = new GoogleReCaptcha.GoogleReCaptcha();
protected override void CreateChildControls()
    ctrlGoogleReCaptcha.PublicKey = "YOUR_SITE_KEY";
    ctrlGoogleReCaptcha.PrivateKey = "YOUR_SECRET_KEY";

After adding the GoogleReCaptcha control, using any of the two above ways the NEW Google ReCaptcha control gets rendered on the page. Now, the next requirement is to validate the Captcha Challenge on form submission.

Validate Captcha Challenge

In order to validate captcha challenge, you just need to call "Validate" method of the GoogleReCaptcha control. The Validate method returns boolean True/False. The sample code is given below:

if (ctrlGoogleReCaptcha.Validate())
   //submit form success
   lblStatus.Text = "Success";
    //captcha challenge failed
    lblStatus.Text = "Captcha Failed!! Please try again!!";


Keep a running update of any changes or improvements you've made here.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Komail Haider
Team Leader 10Pearls
United Arab Emirates United Arab Emirates
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionDoesnt Work Pin
TakoMT6-Sep-16 0:45
memberTakoMT6-Sep-16 0:45 
QuestionQuestion recaptcha v2 Pin
Member 1271419031-Aug-16 22:25
memberMember 1271419031-Aug-16 22:25 
PraiseAnother vote of 5 Pin
matthewproctor20-Jun-16 16:19
professionalmatthewproctor20-Jun-16 16:19 
QuestionHow to reference GoogleReCaptcha.dll in my project VisualStudio2008 Pin
silviapauit6-Jun-16 8:06
membersilviapauit6-Jun-16 8:06 
PraiseCouldn't be better Pin
rejyv16-Feb-16 10:58
memberrejyv16-Feb-16 10:58 
GeneralMy vote of 5 Pin
rejyv16-Feb-16 10:56
memberrejyv16-Feb-16 10:56 
GeneralMy vote of 5 Pin
Member 1031355110-Feb-16 2:10
memberMember 1031355110-Feb-16 2:10 
QuestionValidate always false Pin
Member 123064533-Feb-16 20:38
memberMember 123064533-Feb-16 20:38 
QuestionChange the display language of the reCaptcha 2.0 Pin
Alpine Owl7-Dec-15 5:55
memberAlpine Owl7-Dec-15 5:55 
Questionaudio/size/theme in captcha 2.0 Pin
Member 1213749413-Nov-15 7:27
memberMember 1213749413-Nov-15 7:27 
QuestionThanks for your help Pin
nguyenson0303.tk6se12-Nov-15 18:10
membernguyenson0303.tk6se12-Nov-15 18:10 
QuestionWell done, but ViewState is insecure Pin
esaulsberry22-Sep-15 9:56
memberesaulsberry22-Sep-15 9:56 
AnswerRe: Well done, but ViewState is insecure Pin
ALight224-Nov-15 12:12
memberALight224-Nov-15 12:12 
QuestionNice example! Pin
Member 1198132613-Sep-15 17:24
memberMember 1198132613-Sep-15 17:24 
GeneralMy vote of 5 Pin
Stretch200cm30-Aug-15 9:42
memberStretch200cm30-Aug-15 9:42 
QuestionMessage Removed Pin
Gerry Renner30-Jul-15 10:37
memberGerry Renner30-Jul-15 10:37 
QuestionAsp.NET 3.5 compatibility Pin
ecsoluzioni14-Jul-15 20:59
memberecsoluzioni14-Jul-15 20:59 
AnswerRe: Asp.NET 3.5 compatibility Pin
Alexander Melo23-Jul-15 5:39
memberAlexander Melo23-Jul-15 5:39 
QuestionPerfect Pin
A_ndre9-Jul-15 8:40
memberA_ndre9-Jul-15 8:40 
QuestionIs there a way to get it to work inside UpdatePanel? Pin
DancnDude7-Jul-15 5:57
memberDancnDude7-Jul-15 5:57 
BugCannot be used on GoDaddy Pin
Gambit471-Jul-15 16:59
memberGambit471-Jul-15 16:59 
QuestionCan you hide the "Privacy - Terms" label from the CAPTCHA control Pin
Astak1-Jun-15 13:25
memberAstak1-Jun-15 13:25 
AnswerRe: Can you hide the "Privacy - Terms" label from the CAPTCHA control Pin
Komail Haider15-Jun-15 8:25
memberKomail Haider15-Jun-15 8:25 
GeneralMy vote of 5 Pin
Steve Eagle2-Apr-15 10:13
memberSteve Eagle2-Apr-15 10:13 
GeneralRe: My vote of 5 Pin
Komail Haider2-Apr-15 10:39
memberKomail Haider2-Apr-15 10:39 
GeneralMy vote of 5 Pin
newton.saber9-Mar-15 1:56
membernewton.saber9-Mar-15 1:56 
GeneralRe: My vote of 5 Pin
Komail Haider9-Mar-15 2:47
memberKomail Haider9-Mar-15 2:47 
QuestionNice Effort :) Pin
M I developer9-Mar-15 1:13
memberM I developer9-Mar-15 1:13 
AnswerRe: Nice Effort :) Pin
Komail Haider9-Mar-15 2:47
memberKomail Haider9-Mar-15 2:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.161021.1 | Last Updated 9 Mar 2015
Article Copyright 2015 by Komail Haider
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid