Skip to main content

Posts

Integrating Google reCAPTCHA v2 with an ASP.NET Core Razor Pages form

CAPTCHA ( c ompletely a utomated p ublic T uring test to tell c omputers and h umans a part) reduces the likelihood of automated bots successfully submitting forms on your web site. Google's reCAPTCHA implementation is familiar to users (as these things go), and is a free service. Integrating it within an ASP.NET Core Razor Pages form is straightforward. Obtain Google API key The first thing we need to do is to sign up for an API key pair. The latest documentation for this process can be found on the reCAPTCHA Developer's Guide . Google will provide us with a site key and a secret key . I am storing these keys in the Visual Studio Secret Manager so they are not accidentally checked in with version control. To access the Secret Manager, right-click on the project and select "Manage User Secrets...": No, these are not my real keys... As part of the sign up process for the reCAPTCHA keys, we specify the domains for which the keys are valid. Be sure to add ...