Persilsoft.Recaptcha.Blazor
1.0.21
See the version list below for details.
dotnet add package Persilsoft.Recaptcha.Blazor --version 1.0.21
NuGet\Install-Package Persilsoft.Recaptcha.Blazor -Version 1.0.21
<PackageReference Include="Persilsoft.Recaptcha.Blazor" Version="1.0.21" />
paket add Persilsoft.Recaptcha.Blazor --version 1.0.21
#r "nuget: Persilsoft.Recaptcha.Blazor, 1.0.21"
// Install Persilsoft.Recaptcha.Blazor as a Cake Addin #addin nuget:?package=Persilsoft.Recaptcha.Blazor&version=1.0.21 // Install Persilsoft.Recaptcha.Blazor as a Cake Tool #tool nuget:?package=Persilsoft.Recaptcha.Blazor&version=1.0.21
Persilsoft.Recaptcha.Blazor
It exposes a service that allows you to obtain a reCAPTCHA token and validate that token through a verification endpoint that you need to add to your backend.
Example
First, you need to register the following service group in the dependency container.
using Persilsoft.Recaptcha.Blazor.Options;
using ServiceCollectionExtensions;
Action<RecaptchaOptions> recaptchaOptionsConfigurator = options =>
builder.Configuration.GetSection(RecaptchaOptions.SectionKey).Bind(options);
builder.Services.AddRecaptchaServices(recaptchaOptionsConfigurator);
In the appsetting.json configuration file, you need to configure the following key:
"RecaptchaOptions": {
"WebApiBaseAddress": "https://persilsoft.api",
"VerifyRecaptcha": "/recaptcha/verify",
"SiteKey": "xxxxxxxxxxx"
}
Where:
WebApiBaseAddress: It is the Base URL of your backend server that will expose the token verification endpoint.
VerifyRecaptcha: It is the token verification endpoint on your backend server.
SiteKey: It is your website key, also known as the reCAPTCHA key.
Now, you can use the service in your Razor page.
@page "/recaptcha"
@using Persilsoft.Recaptcha.Shared.Interfaces
@inject IRecaptchaService RecaptchaService
<h3>Demo</h3>
<EditForm Model="@model" OnValidSubmit="Send">
<DataAnnotationsValidator />
<div class="mb-3">
<label for="name" class="form-label">Nombre</label>
<input type="text" @bind="model.Name" class="form-control" id="name" name="name" />
<ValidationMessage For="@(() => model.Name)" />
</div>
<div class="d-grid gap-2 col-6 mx-auto">
<button class="btn btn-danger" type="submit">Enviar</button>
</div>
<hr />
<div class="mt-3">
<textarea disabled class="form-control">
@result
</textarea>
</div>
</EditForm>
@code {
private readonly PersonModel model = new();
private string result;
private async Task Send()
{
try
{
await RecaptchaService.TryVerifyInteractionAsync();
result = "Successful validation!!!";
}
catch (Exception ex)
{
result = ex.Message;
}
}
public class PersonModel
{
[Required(ErrorMessage = "{0} is required.")]
public string Name { get; set; }
}
}
Note: The invocation of the TryVerifyInteractionAsync method will throw an exception if the reCAPTCHA validation process fails.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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. |
-
net8.0
- Microsoft.AspNetCore.Components.Web (= 8.0.7)
- Microsoft.Extensions.Http (= 8.0.0)
- Persilsoft.Blazor.JSInterop (= 1.0.6)
- Persilsoft.HttpDelegatingHandlers (= 1.0.12)
- Persilsoft.Recaptcha.Shared (= 1.0.5)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Persilsoft.Recaptcha.Blazor:
Package | Downloads |
---|---|
Persilsoft.Membership.Blazor
Contains razor clases for use in frontend membership projects |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.31 | 171 | 10/16/2024 |
1.0.30 | 101 | 10/16/2024 |
1.0.29 | 59 | 10/15/2024 |
1.0.28 | 103 | 10/14/2024 |
1.0.27 | 102 | 10/6/2024 |
1.0.26 | 95 | 10/4/2024 |
1.0.25 | 100 | 10/4/2024 |
1.0.24 | 111 | 9/1/2024 |
1.0.23 | 129 | 8/28/2024 |
1.0.22 | 85 | 8/28/2024 |
1.0.21 | 113 | 8/18/2024 |
1.0.20 | 104 | 8/18/2024 |
1.0.19 | 112 | 8/17/2024 |
1.0.18 | 103 | 8/17/2024 |
1.0.17 | 114 | 8/17/2024 |
1.0.16 | 75 | 7/29/2024 |
1.0.15 | 244 | 7/20/2024 |
1.0.14 | 274 | 5/26/2024 |
1.0.13 | 93 | 5/26/2024 |
1.0.12 | 213 | 5/25/2024 |
1.0.11 | 110 | 5/25/2024 |
1.0.10 | 116 | 5/25/2024 |
1.0.9 | 144 | 5/23/2024 |
1.0.8 | 260 | 5/18/2024 |
1.0.7 | 119 | 5/18/2024 |
1.0.6 | 152 | 5/17/2024 |
1.0.5 | 134 | 5/5/2024 |
1.0.4 | 120 | 5/4/2024 |
1.0.3 | 71 | 5/3/2024 |
1.0.2 | 82 | 5/1/2024 |
1.0.1 | 103 | 4/24/2024 |
1.0.0 | 107 | 4/22/2024 |