# ASP.NET MVC Captcha Overview

The Telerik UI Captcha HtmlHelper for ASP.NET MVC is a server-side wrapper for the Kendo UI DataSource widget.

The Telerik UI Captcha for ASP.NET MVC is a security measure that prevents automated spam from performing tasks such as form submissions in your ASP.NET MVC application. The widget generates distorted images of letters and numbers that are easily decipherable to humans, but not to automated programs (spam bots).

* [Demo page for the Captcha HtmlHelper](https://demos.telerik.com/aspnet-mvc/captcha/index)

## Basic Configuration

The following example demonstrates the basic configuration of the Captcha component. For the full server-side implementation, consider the [Validation article](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/captcha/validation).

```Razor HtmlHelper
    @(Html.Kendo().Captcha()
        .Name("Captcha")
        .Handler(handler => handler.Action("Reset", "Captcha")) // endpoint to return the CAPTCHA 
        .AudioHandlerFunction("audioHandler") // handler to fetch audio representation of the CAPTCHA (if needed)
        .ValidationHandler(handler => handler.Action("Validate", "Captcha")) // enpoint to validate the CAPTCHA
    )
```

```JavaScript
    <script>
        function audioHandler(args) {
            args.success("@Url.Action("Audio")?captchaId=" + args.data.captchaId); 
        }
    </script>
```

```C#
public ActionResult Reset()
{
    CaptchaImage newCaptcha = SetCaptchaImage();

    return Json(new CaptchaModel
    {
        Captcha = "./shared/UserFiles/captcha/" + newCaptcha.UniqueId + ".png",
        CaptchaID = newCaptcha.UniqueId
    });
}

public ActionResult Validate(CaptchaModel model)
{
    string text = GetCaptchaText(model.CaptchaID);

    return Json(text ==  model.Captcha.ToUpperInvariant());
}

private string GetCaptchaText(string captchaId)
{
    string text = HttpContext.Session.GetString("captcha_" + captchaId);

    return text;
}
```

## Functionality and Features

* [Captcha Server-side Provider](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/captcha/provider)—You can implement a server-side provider for the Captcha component.
* [Validation](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/captcha/validation)—The Captcha offers validation capabilities.
* [Audio Content](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/captcha/audio)—You can present your own audio content to the user.
* [Accessibility](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/captcha/accessibility/overview)—The Captcha and the entire Telerik toolset implement convenient accessibility features.

## Events

For a complete example on the Captcha's events, refer to the [demo on using the events of the Captcha](https://demos.telerik.com/aspnet-mvc/captcha/events).

## Referencing Existing Instances

To reference an existing Captcha instance, use the [`jQuery.data()`](https://api.jquery.com/jQuery.data/) configuration option. Once a reference is established, use the [Captcha client-side API](https://docs.telerik.com/kendo-ui/api/ui/captcha#methods) to control its behavior.

```JavaScript
    // Place the following after your Telerik UI Captcha for ASP.NET MVC declaration.
    <script>
        $(document).ready(function() {
            // The Name() of the Captcha is used to get its client-side instance.
            var captcha = $("#Captcha").data("kendoCaptcha");
        });
    </script>
```

## Next Steps

* [Getting Started with the Captcha](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/captcha/getting-started)
* [Basic Usage of the Captcha for ASP.NET MVC (Demo)](https://demos.telerik.com/aspnet-mvc/captcha/index)

## See Also

* [Using the API of the Captcha (Demo)](https://demos.telerik.com/aspnet-mvc/captcha/api)
* [Knowledge Base Section](https://www.telerik.com/aspnet-mvc/documentation/knowledge-base)
