Google RECaptcha Error: Captcha validation is required in ASP.Net

Last Reply 6 months ago By etherjazz

Posted 6 months ago

I have successfully used the reCAPTCHA example byMudassar Ahmed Khan in the past and love its simplicity. The URL for this approach is:

https://www.aspsnippets.com/Articles/Google-RECaptcha-Code-with-Example-in-ASPNet.aspx

This article comes with example code that makes it easy to test it on a new website before integrating with other pages. I'm an old time VB programmer so I use the VB.aspx example.

The problem I'm running into is that on some web sites in my projects the success code being returned from Google does not get populated to the hidden textbox on the form. The Google widget shows success, but the text (which should be 'true') does not get placed into the text box.

The result of this is that the Required Field Validator throws an error saying "Captcha validation is required."

I'm not sure what's causing this. I have valid reCAPTCHA site/secret codes from Google. The only thing I can think of is that there may be some setting in IIS or in the .NET framework that needs to be changed.

Any suggestions would be appreciated.

You are viewing reply posted by: etherjazz 6 months ago.
Posted 6 months ago

After a bunch of testing I figured out what was causing the problem. The websites where I encountered the error were those that were set up on https servers (with SSL).

In the article in ASP Snippets where I got the code there is a section called RECaptcha Client Side Implementation and Validation. The first line of code is a JavaScript link that has the following URL:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>

In an old article about reCAPTCHA 1 I learned that SSL sites need to have https links for these scripts. So I changed this one line of code in one of my SSL sites to this:

 <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>

The only difference between these two lines is that the src for the second one begins with "https:" When I made this one simple change, the reCAPTCHA routine worked perfectly in all of the sites where the domains are on https servers.

A big thank you to Mudassar Ahmed Khan for the original code. His contributions in the ASP Snippets website are the best!