Pandorax.Recaptcha
3.1.0
dotnet add package Pandorax.Recaptcha --version 3.1.0
NuGet\Install-Package Pandorax.Recaptcha -Version 3.1.0
<PackageReference Include="Pandorax.Recaptcha" Version="3.1.0" />
<PackageVersion Include="Pandorax.Recaptcha" Version="3.1.0" />
<PackageReference Include="Pandorax.Recaptcha" />
paket add Pandorax.Recaptcha --version 3.1.0
#r "nuget: Pandorax.Recaptcha, 3.1.0"
#:package Pandorax.Recaptcha@3.1.0
#addin nuget:?package=Pandorax.Recaptcha&version=3.1.0
#tool nuget:?package=Pandorax.Recaptcha&version=3.1.0
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
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
When validating a reCAPTCHA response, you should check the following properties on the validation response:
Success
: Indicates whether the validation was successful.Score
: Represents the confidence score (for reCAPTCHA v3). You may want to set a threshold (e.g., 0.5).Action
: Should match the expected action you specified when rendering the reCAPTCHA widget.
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);
if (validationResponse.Success)
{
// reCAPTCHA validation succeeded
if (validationResponse.Score >= 0.5)
{
// High confidence in the user's interaction
if (validationResponse.Action == "submit_form")
{
// Action matches expected value
}
else
{
// Action does not match expected value
}
}
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. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.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.1.0 | 137 | 6/2/2025 | |
3.1.0-alpha001 | 138 | 6/2/2025 | |
3.0.0 | 132 | 6/2/2025 | |
3.0.0-alpha003 | 115 | 2/13/2025 | |
3.0.0-alpha002 | 734 | 10/20/2022 | |
3.0.0-alpha001 | 214 | 10/13/2022 | |
2.1.1 | 9,622 | 10/6/2021 | |
2.1.0 | 743 | 7/14/2021 | |
2.0.1 | 749 | 5/26/2021 | |
1.2.0 | 3,198 | 2/24/2020 | |
1.1.0 | 544 | 2/24/2020 | |
1.0.0-alpha1 | 972 | 11/26/2019 |