Add CAPTCHA to the Registration form widget

Overview

To improve security, you can add a CAPTCHA to the Registration form widget. You can use the provided Google reCAPTCHA templates or plug in your own CAPTCHA.

PREREQUISITES: Before using Google reCAPTCHA, you must:
  • Register your site get an API key pair at Google reCAPTCHA.
    You can generate an API key for either reCAPTCHA v2 or reCAPTCHA v3 and then use it with the corresponding widget from this tutorial.
  • You must update your privacy and GDPR statements according to Google reCAPTCHA policies

Configure CAPTCHA settings

Perform the following: 

  1. In Sitefinity backend, navigate to Administration » Settings » Advanced.
  2. In the treeview, expand WebSecurity » Captcha and click Parameters.
  3. Configure the following parameters:
    • Key VerificationUrl and Value https://www.google.com/recaptcha/api/siteverify
    • Key SecretKey and Value <The secret from the API key pair that you have created>
    • Key EnableCaptchaValidation and Value true
      This will enable the CAPTCHA validation in the Registration form widget.
  4. Save your changes.

Create the CAPTCHA Registration widget template

Create a custom template for the Registration form widget in the following way:

  1. Open your project in Visual Studio.
  2. In folder Views/Shared/Components, create a new folder and name it SitefinityRegistration
  3. In the context menu of folder SitefinityRegistration, click Add » New Item…
  4. Depending on which version of CAPTCHA you want to use, perform one of the following:
  1. Name the file RegistrationWithCaptchaDemoV2.cshtml, and click Add
  2. In the template paste the following code:

  3. In the template, change the <your_site_key> variable to have as value your site.
  4. Save your changes and build your solution.
  1. Name the file RegistrationWithCaptchaDemoV3.cshtml, and click Add
  2. In the template paste the following code:

  3. In the template, change the <your_site_key> variable to have as value your site.
  4. Save your changes and build your solution.

Apply the CAPTCHA template

Perform the following:

  1. Open the page where the Registration form widget is located for editing.
  2. In the page editor, hover over the Registration form widget.
  3. Click the toggle menu in the widget label.
  4. Click Edit (Edit).
  5. In the Registration template dropdown box, select the new template.
  6. Save your changes.

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?