No Captcha ReCaptcha 2.0 with ASP.NET using VB.NET is easy to set up and use with this code to stop bots and minimize spammers. Google's new No Captcha ReCaptcha 2.0 with ASP.NET integration will allow everyone using VB.NET on their websites to add this new tool to their arsenal to help combat bots and slow down spammers.
Live Lessons Example - No Captcha ReCaptcha 2.0 with ASP.NET (VB Version)
Shahid Shaikh from codeforgeek.com« (Article is no longer available.) His response got me pointed in the right direction.
You will need the new reCAPTCHA 2.0 Site Key. Go here: https://www.google.com/recaptcha/admin«. Add a new Site Key for your website. For local testing, you will have to test with 127.0.0.1/Load.aspx It will not work with a static IP Address or with localhost anymore.
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Load.aspx.vb" Inherits="Load" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src='https://www.google.com/recaptcha/api.js'></script>
</head>
<body>
<form runat="server">
<label>Name</label>
<asp:TextBox ID="name" runat="server"></asp:TextBox>
<%
'You will need the new reCAPTCHA 2.0 Site Key for this.
'Go here: https://www.google.com/recaptcha/admin
'And add a new Site Key for your website.
'For local testing, you will have to test with
'local/site.asp
'127.0.1/site.asp
'It will not work with a static IP Address as I would prefer.
%> <asp:Button ID="Button1" runat="server" Text="Button" />
<div class="g-recaptcha" data-sitekey="6LeGzQATAAAAAGglcdHMRAuR8IOAdAFD47HpCZRQ"></div>
<asp:Label ID="Label1" runat="server"></asp:Label>
</form>
</body>
</html>
ProtectedSub Button1_Click(sender AsObject, e As EventArgs) Handles Button1.ClickDim strname AsString = name.TextDim captcha AsString = Request.Form("g-recaptcha-response")
'Next, we are going to make sure that each form variable has a value (Meaning: Filled out)
If strname = "" ThenLabel1.Text = "Please provide your name"
'Next, we are going to challenge the reCAPTCHA to make sure that it is not blank,
'and there is NO way around this. If it is not blank, then we send them a message.
ElseIf captcha = "" ThenLabel1.Text = "You have not completed the <strong>reCAPTCHA</strong>
Please click on the blank box.
Thanks You"
Else 'If the user has completed the reCAPTCHA, then we send a message letting them know.
Label1.Text = "Thank you for trying out the
<strong>ASP.NET (VB Version) / Jquery reCAPTCHA 2.0</strong> demo."
End IfEndSub