Pandorax.Recaptcha
3.0.0-alpha003
dotnet add package Pandorax.Recaptcha --version 3.0.0-alpha003
NuGet\Install-Package Pandorax.Recaptcha -Version 3.0.0-alpha003
<PackageReference Include="Pandorax.Recaptcha" Version="3.0.0-alpha003" />
paket add Pandorax.Recaptcha --version 3.0.0-alpha003
#r "nuget: Pandorax.Recaptcha, 3.0.0-alpha003"
// Install Pandorax.Recaptcha as a Cake Addin #addin nuget:?package=Pandorax.Recaptcha&version=3.0.0-alpha003&prerelease // Install Pandorax.Recaptcha as a Cake Tool #tool nuget:?package=Pandorax.Recaptcha&version=3.0.0-alpha003&prerelease
Pandorax.Recaptcha
This project is a library for validating Google reCAPTCHA responses in .NET applications.
Installation
To install the library, add the following NuGet package to your project:
dotnet add package Pandorax.Recaptcha
dotnet add package Pandorax.Recaptcha.DependencyInjection
Usage
Configuration
First, configure the reCAPTCHA options in your appsettings.json
:
{
"Recaptcha": {
"SiteKey": "your-site-key",
"SecretKey": "your-secret-key"
}
}
Then, register the reCAPTCHA services in your Startup.cs
or Program.cs
:
public void ConfigureServices(IServiceCollection services)
{
services.AddRecaptcha(Configuration.GetSection("Recaptcha"));
}
Or, if you are using Program.cs
with top-level statements:
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRecaptcha(builder.Configuration.GetSection("Recaptcha"));
Validation
To validate a reCAPTCHA response, inject the IRecaptchaService
into your controller or service and call the ValidateAsync
method:
public class MyController : Controller
{
private readonly IRecaptchaService _recaptchaService;
public MyController(IRecaptchaService recaptchaService)
{
_recaptchaService = recaptchaService;
}
[HttpPost]
public async Task<IActionResult> SubmitForm(string recaptchaResponse)
{
var validationResponse = await _recaptchaService.ValidateAsync(recaptchaResponse, HttpContext.Connection.RemoteIpAddress.ToString());
if (validationResponse.Success)
{
// reCAPTCHA validation succeeded
if (validationResponse.Score >= 0.5)
{
// High confidence in the user's interaction
}
else
{
// Low confidence in the user's interaction
}
}
else
{
// reCAPTCHA validation failed
}
return View();
}
}
License
This project is licensed under the MIT License.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. 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 is compatible. 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. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net6.0
- Microsoft.Extensions.Http (>= 6.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 6.0.0)
-
net8.0
- Microsoft.Extensions.Http (>= 8.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 8.0.0)
-
net9.0
- Microsoft.Extensions.Http (>= 9.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Pandorax.Recaptcha:
Package | Downloads |
---|---|
Pandorax.Recaptcha.DependencyInjection
Pandorax.Recaptcha extensions for ASP.NET Core |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
3.0.0-alpha003 | 38 | 2/13/2025 | |
3.0.0-alpha002 | 474 | 10/20/2022 | |
3.0.0-alpha001 | 170 | 10/13/2022 | |
2.1.1 | 8,891 | 10/6/2021 | |
2.1.0 | 626 | 7/14/2021 | |
2.0.1 | 687 | 5/26/2021 | |
1.2.0 | 3,104 | 2/24/2020 | |
1.1.0 | 460 | 2/24/2020 | |
1.0.0-alpha1 | 892 | 11/26/2019 |