Pandorax.Recaptcha 3.0.0-alpha003

This is a prerelease version of Pandorax.Recaptcha.
dotnet add package Pandorax.Recaptcha --version 3.0.0-alpha003                
NuGet\Install-Package Pandorax.Recaptcha -Version 3.0.0-alpha003                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Pandorax.Recaptcha" Version="3.0.0-alpha003" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Pandorax.Recaptcha --version 3.0.0-alpha003                
#r "nuget: Pandorax.Recaptcha, 3.0.0-alpha003"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.1.0 is deprecated because it is no longer maintained and has critical bugs.
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