This example adds Google reCAPTCHA to a DevExpress Blazor Form Layout. The Form Layout contains DevExpress Blazor Data Editors, but a DevExpress-specific implementation is not required. Integration steps are the same as any data entry form using any combination of data editor controls.
Refer to the following page for additional information when integrating reCAPTCHA: reCAPTCHA - Developer's Guide.
- Register your website and obtain site and secret keys from Google reCAPTCHA service.
- Create a reusable ReCaptchaComponent that loads Google reCAPTCHA APIs and renders the widget using JavaScript interop.
- Within the ReCaptchaComponent implementation, use Google reCAPTCHA APIs to handle success and expiration callbacks. Verify the captcha response using the Google verification service.
- Add a ReCaptchaComponent to a Form Layout component. Bind site and secret keys to the component.
- Handle success and expiration events to modify a flag variable (track captcha status).
Note: This solution obtains keys from the following environment variables: RECAPTCHA_SITE_KEY
and RECAPTCHA_SECRET_KEY
. If these variables are not set, the application throws an exception (to indicate missing configuration). You can adapt our implementation and retrieve keys from other sources, such as appsettings.json or a configuration file.
(you will be redirected to DevExpress.com to submit your response)