Generates a captcha image for a Blazor Server application.
To Install
Install-Package BlazorCaptcha
or
dotnet add package BlazorCaptcha
For client-side and server-side Blazor - add script section to _Host.cshtml (head section)
<link href="_content/BlazorCaptcha/captcha.css" rel="stylesheet" />
@page "/"
@using BlazorCaptcha
<h3>Hello, world!</h3>
<Captcha @bind-CaptchaWord="@Captcha" CharNumber="@CaptchaLetters" />
<p>@Captcha</p>
@code{
private string Captcha = "";
private int CaptchaLetters = 5;
protected override Task OnInitializedAsync()
{
Captcha = BlazorCaptcha.Tools.GetCaptchaWord(CaptchaLetters);
return base.OnInitializedAsync();
}
}
- Change the parameter "CaptchaWord" => "@bind-CaptchaWord"
- Add the parameter with the length of the word ex : "CharNumber="@CaptchaLetters"
- Remove the "OnRefresh" parameter