Skip to content

pigivc/AudioCaptchaCore

Repository files navigation

AudioCaptchaCore

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<<<<<<<<<

Instructions

  1. Add a
    Pigi.Captcha.dll
    reference to your project. or Install via Nuget Package Manager:
Install-Package Pigi.Captcha -Version 1.0.7
  1. In startup.cs file or your asp.net core project add

    @using Pigi.Captcha
    at the top.

  2. Add

    services.AddPigiCaptcha();
    to the
    ConfigureServices
    method.

  3. Add

    app.ConfigPigiCaptcha();
    to the
    Configure
    method.

  4. When hosting make sure

    Load User Profile
    is set to
    true
    in your IIS application pool > advanced settings (this is not required if you disable audio feature)

  5. 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>
  1. You can configure other settings.

  2. Then validate captcha in code like this:

     
[HttpPost]
public IActionResult Index(string c1)
{
var isCaptcha1Valid = CaptchaManager.ValidateCurrentCaptcha("c1", c1); ViewBag.c1 = isCaptcha1Valid; return View(); }

Live Demo

Demo