1001binary/recaptcha-mvc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The .NET library for integrating Google Recaptcha V3 into ASP.NET MVC 3 and higher.

Source: image from Google

  • Suppose you have a ASP.NET MVC project.
  • Go to Google Recaptcha V3 to get client key and secret key.
  • Install RecaptchaMvc.NET via Nuget.
  • Download the sample project from this repository.
  • Follow it to integrate Google Recaptcha V3 into your web application.
  • HtmlHelper.SetupHiddenRecaptcha: insert the recaptcha hidden field.
  • HtmlHelper.SetupClientScript: insert the Google Recaptcha v3 script and lib's script to display captcha.
  • CommonHelper.ValidateRecaptchaV3: validate the captcha against secret key and token.
  • CommonHelper.AddErrorAndRedirectToGetAction: add error to TempData and redirects to the current action.
  • CommonHelper.RedirectToUrl: redirects to a specific action.
  • CommonHelper.AddErrorToModelState(by default): adds an error message to ModelState in the current action.

This filter is used for verifying the captcha for a number of required URLs. This accepts three parameters:

  • SecretKey: the secret key of Google Recaptcha V3 service.
  • FilterItems: a number of conditions which are valid for the catpcha verification.
  • OnFailure: in case the catpcha verification is failed, this action will be executed. By default, CommonHelper.AddErrorToModelState
  • RecaptchaFieldName: the HTML field name of the captcha. By default, recaptcha_response.

Any feedback are appreciated a lot.

  • Supports ASP.NET MVC 3 and higher.

©Copyright 2020 by 1001binary MIT License

About

The .NET library for integrating Google Recaptcha V3 into ASP.NET MVC 3 and higher 🌴.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published