Audio Captcha for AspNet Core MVC
Enable Audio feature only if you are gonna host your asp.net core app in windows platform. or disable audio or implement your own tts audio relative to your selected hosting platform!
Sample project included!
and be sure to copy 'ttsExec.exe' and 'libmp3lame.64.dll' 'libmp3lame.32.dll' (Included in nuget package) in bin directory of main project<<<<<<<<<
- Add a
Pigi.Captcha.dll
reference to your project. or Install via Nuget Package Manager:
Install-Package Pigi.Captcha -Version 1.0.7
-
In startup.cs file or your asp.net core project add
@using Pigi.Captcha
at the top. -
Add
services.AddPigiCaptcha();
to theConfigureServices
method. -
Add
app.ConfigPigiCaptcha();
to theConfigure
method. -
When hosting make sure
Load User Profile
is set totrue
in your IIS application pool > advanced settings (this is not required if you disable audio feature) -
Sample use in a view.cshtm:
@Html.Captcha(new CaptchaSettings { Id = "c1", TextLength = 5 })
or
<captcha for-id="c2" for-textLength="9" for-showInput="false" for-textStyle="TextStyle.Numeric"></captcha>
-
You can configure other settings.
-
Then validate captcha in code like this:
[HttpPost]
public IActionResult Index(string c1)
{
var isCaptcha1Valid = CaptchaManager.ValidateCurrentCaptcha("c1", c1); ViewBag.c1 = isCaptcha1Valid; return View(); }