[C#][ASP NET Core] 快速将 Google reCAPTCHA 验证加入你的网站

LexLibrary.Google.reCAPTCHA

使用 HtmlHelper + ValidateAttribute 快速将 Google reCAPTCHA 验证加入你的网站

Blog:https://blog.exfast.me/2018/11/c-sharp-asp-net-core-quickly-add-google-recaptcha-verification-to-your-website/

NuGet:https://www.nuget.org/packages/LexLibrary.Google.reCAPTCHA/

GitHub:https://github.com/shuangrain/LexLibrary.Google.reCAPTCHA

Support

  • [ ] Google reCAPTCHA v1
  • [x] Google reCAPTCHA v2
  • [x] Google reCAPTCHA v3

Example

添加设置档到 Startup.cs

services.AddGoogleCaptcha(new GoogleCaptchaSetting { })

View

@Html.GooglereCaptchaV2()
@Html.GooglereCaptchaV3("/login")

Controller

[GoogleCaptchaValidate(Version = GoogleCaptchaVersion.v2, ErrorMessage = "验证失败,请重新再试。")]
[GoogleCaptchaValidate(Version = GoogleCaptchaVersion.v3, ErrorMessage = "验证失败,请重新再试。")]

发表评论