Google reCAPTCHA in ASP.NET MVC. ReCAPTCHA protects the websites you love from spam and abuse. Google has updated their reCAPTCHA API to 2.0. Now, users can attest they are human without having to solve a CAPTCHA. Instead with just a single click, they’ll confirm they are not a robot and it is called as “ No CAPTCHA reCAPTCHA “. This is how new reCAPTCHA looks. Google recently announced a newer version of reCAPTCHA, called No CAPTCHA, that eliminates the “I’m not a robot” checkbox all together, unless a user is flagged as “suspicious.” If someone fails to input the correct password one too many times, for example, the box would appear, or users would have to undergo more rigorous security checks.
Google ReCaptcha for Asp Net, simplified
Installation
Nuget Url:https://www.nuget.org/packages/ReCaptcha-AspNet
Configuration
Get your secret and public keys on https://www.google.com/recaptcha/admin
Add to you App/Web.config inside
Optional if you want to alter the default language of the Captcha (Get the language code on ReCaptcha site: https://developers.google.com/recaptcha/docs/language)Or you can use value 'Auto' and it will get the Language from System.Thread.CurrentCulture
Or via C# code:It's only needed to call it once, a good place to put this is at Application_Start() function
How to use
Client Side (v2):
Inside your form
Optional if you want to override your configured default language:
Client Side (Invisible):
Inside your form
Optional if you want to override your configured default language:
Server Side:
Inside your controller function or in a filter
Optional: Proxy
You may use a Proxy to send user Response to ReCaptcha Server
May throws the following exception, if the secret key is invalid, or you pass a invalid user response as the ValidateCaptcha parameter:
It can also be called async: