Signing up for reCAPTCHA can be done here: https://www.google.com/recaptcha/about/. Once signed up, you will be guided through creating a new site (reCAPTCHA v2).
In the following steps, we will need both a reCAPTCHA Site Key and Secret Key. Bot keys are found on the settings screen on the new site:
reCAPTCHA is added by including the JavaScript from Google somewhere. For ASP.NET Core add it to the Scripts
section:
@section Scripts { <script src="https://www.google.com/recaptcha/api.js" async defer></script> <partial name="_ValidationScriptsPartial" /> </script>
Next, you will need to tell reCAPTCHA where to put the CAPTCHA control. Paste the following markup inside the form
element:
<div class="form-group"> <div class="g-recaptcha" data-sitekey="SITE_KEY"></div> </div>
For the data-sitekey
attribute, use the reCAPTCHA site key from the site settings.