How to use googles new recaptcha I am not a robot in asp net


ASP.NET is a popular programming language used for developing web applications. In this article, we will explore how to use Google's new reCAPTCHA “I am not a robot” in ASP.NET.

What is reCAPTCHA?

reCAPTCHA is a free service provided by Google that helps protect websites from spam and abuse. It uses advanced risk analysis techniques to distinguish between humans and bots. The “I am not a robot” is a user-friendly way to verify that the user is indeed a human.

Step 1: Obtaining reCAPTCHA API Keys

In order to use reCAPTCHA in your ASP.NET application, you need to obtain API keys from the reCAPTCHA website. Follow these steps:

  1. Go to the reCAPTCHA website (
  2. Click on the “ ” button located at the top right corner of the page.
  3. Sign in with your Google account or create a new one if you don't have it.
  4. Register a new site by providing a label and the domain where you will be using reCAPTCHA.
  5. After registration, you will receive a Site Key and a Secret Key. These keys will be used in your ASP.NET application.

Step 2: reCAPTCHA to your ASP.NET Application

Now that you have obtained the API keys, let's see how to integrate reCAPTCHA into your ASP.NET application.

First, add the following code at the beginning of your ASP.NET code:

using System;
using System.Web.UI.WebControls;
using Google.Recaptcha;

Next, add the reCAPTCHA control to your ASP.NET page:

“YOUR_SITE_KEY” and “YOUR_SECRET_KEY” with the keys obtained in Step 1.

Step 3: Validating reCAPTCHA

After adding the reCAPTCHA control, you need to validate it on the server-side to that the user is not a robot.

Add the following code to your ASP.NET code:

protected void btnSubmit_Click(object sender, EventArgs e)
    if (recaptcha.IsValid)
        // reCAPTCHA validation , continue with your 
        // reCAPTCHA validation failed, show an error message

In the above code, we check if the reCAPTCHA control is valid using the “IsValid” property. If it is valid, you can proceed with your logic. Otherwise, you can an error message to the user.


By following the steps mentioned above, you can easily integrate Google's new reCAPTCHA “I am not a robot” into your ASP.NET application. This will help protect your website from spam and abuse, ensuring a better user for your visitors.

Rate this post

Leave a Reply

Your email address will not be published. Required fields are marked *

Table of Contents