reCAPTCHA.AspNetCore
1.0.0
See the version list below for details.
dotnet add package reCAPTCHA.AspNetCore --version 1.0.0
NuGet\Install-Package reCAPTCHA.AspNetCore -Version 1.0.0
<PackageReference Include="reCAPTCHA.AspNetCore" Version="1.0.0" />
paket add reCAPTCHA.AspNetCore --version 1.0.0
#r "nuget: reCAPTCHA.AspNetCore, 1.0.0"
// Install reCAPTCHA.AspNetCore as a Cake Addin #addin nuget:?package=reCAPTCHA.AspNetCore&version=1.0.0 // Install reCAPTCHA.AspNetCore as a Cake Tool #tool nuget:?package=reCAPTCHA.AspNetCore&version=1.0.0
reCAPTCHA.AspNetCore
Google reCAPTCHA for ASP.NET Core 2
Requirements
You must first have a secret key and a site key in order to use the reCAPTCHA service. You can read more about reCAPTCHA as well as sign up for free here: https://www.google.com/recaptcha/intro/
Configure
Right click on your project file and goto Manage Secrets.
This will open secrets.json. Add the follow entry to the file make sure to paste in your secret key and site key:
"RecaptchaSettings": {
"SecretKey": "paste secret key here",
"SiteKey": "paste site key here"
}
Now open Startup.cs and add the following code as shown below to your ConfigureServices method:
services.Configure<RecaptchaSettings>(Configuration.GetSection("RecaptchaSettings"));
services.AddTransient<IRecaptchaService, RecaptchaService>();
Usage
In order to prevent having to copy and paste your site key all over your view files (a nightmare to update later). You can inject your settings from the Startup method by adding the following code to top of your view file:
@inject IOptions<RecaptchaSettings> RecaptchaSettings
You can then freely include the Recaptcha script inside of forms you wish to vaidate later in your controller (supports multiple forms).
@using (Html.BeginForm("SomeMethod", "SomeController")) {
@Html.Recaptcha(RecaptchaSettings.Value.SiteKey)
}
Validation
In order to validate a recaptcha script being used in a form you will first need to inject the IRecaptchaService class into your controller using the code below:
private IRecaptchaService _recaptcha;
public SomeController(IRecaptchaService recaptcha)
{
_recaptcha = recaptcha;
}
Finally you can validate the recaptcha attempts using the Validate method in the Recaptcha service in your HttpPost method:
[HttpPost]
public async Task<IActionResult> SomeMethod(SomeModel model)
{
var valid = await _recaptcha.Validate(Request);
return View();
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 is compatible. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
-
.NETCoreApp 2.0
- Microsoft.AspNetCore.Mvc.ViewFeatures (>= 2.0.0)
- Microsoft.NETCore.App (>= 2.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on reCAPTCHA.AspNetCore:
Package | Downloads |
---|---|
FenixAlliance.ACL.Dependencies
Application Component for the Alliance Business Suite. |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on reCAPTCHA.AspNetCore:
Repository | Stars |
---|---|
poppastring/dasblog-core
The original DasBlog reimagined with ASP.NET Core
|
Version | Downloads | Last updated |
---|---|---|
3.0.10 | 1,033,328 | 8/26/2020 |
3.0.9 | 743 | 8/25/2020 |
3.0.8 | 1,525 | 8/22/2020 |
3.0.7 | 3,432 | 8/12/2020 |
3.0.6 | 14,421 | 7/10/2020 |
3.0.5 | 2,611 | 6/25/2020 |
3.0.4 | 10,812 | 6/24/2020 |
3.0.3 | 19,197 | 5/8/2020 |
3.0.2 | 4,051 | 5/4/2020 |
3.0.1 | 869 | 5/4/2020 |
3.0.0 | 1,073 | 5/3/2020 |
2.2.5 | 31,459 | 5/2/2020 |
2.2.3 | 170,777 | 4/15/2019 |
2.2.2 | 3,643 | 4/11/2019 |
2.2.1 | 1,072 | 4/9/2019 |
2.2.0 | 1,879 | 4/8/2019 |
2.1.3 | 34,660 | 1/12/2019 |
2.1.2 | 1,446 | 1/4/2019 |
2.1.1 | 2,564 | 11/24/2018 |
2.1.0 | 2,051 | 10/13/2018 |
2.0.0 | 1,397 | 9/20/2018 |
1.0.1 | 4,306 | 11/5/2017 |
1.0.0 | 1,367 | 11/1/2017 |