BotDetect Ajax CAPTCHA Documentation

This page is an index of BotDetect Captcha documentation regarding Ajax Captcha validation: code examples, how to guides and Ajax implementation options available in different versions of BotDetect.

Related information can be found in similar pages about jQuery Captcha and JavaScript Captcha.

Ajax CAPTCHA in ASP.NET

There are several different approaches you can take when implementing Ajax Captcha validation of BotDetect ASP.NET Captcha, depending on your Ajax framework of choice and the amount and format of data exchanged by the client and server during Captcha validation through Ajax requests.

jQuery Ajax CAPTCHA Validation

If your website uses jQuery, see BotDetect documentation about jQuery Captcha in ASP.NET.

ASP.NET Ajax CAPTCHA Validation

BotDetect CAPTCHA can be used within ASP.NET Ajax UpdatePanel controls using the same code as in regular ASP.NET forms. However, some additional work is required if BotDetect is not visible on the first page load, but gets added to the page dynamically. This approach is demonstrated in the BotDetect ASP.NET Ajax code example:

ASP.NET Ajax Version Default Source Code Folder Online Source
ASP.NET Ajax 4.5 C:\Program Files\Captcha Inc\BotDetect 4 CAPTCHA Component\Asp.Net\.NET4.5\WebApp\ AspNetWebFormsAjaxCaptchaExample
ASP.NET Ajax 4.0 C:\Program Files\Captcha Inc\BotDetect 4 CAPTCHA Component\Asp.Net\.NET4.0\WebApp\ AspNetAjax40CaptchaExample
ASP.NET Ajax 1.0 C:\Program Files\Captcha Inc\BotDetect 4 CAPTCHA Component\Asp.Net\.NET3.5\WebApp\ AspNetAjax10CaptchaExample

ASP.NET Unobtrusive Validation Ajax Captcha

BotDetect Captcha can be validated as part of ASP.NET unobtrusive validation of form fields in both ASP.NET MVC and ASP.NET WebForms applications. This approach to Ajax Captcha validation is shown in the ASP.NET MVC application template Captcha example and the ASP.NET 4.5 WebForms application template Captcha example.

Getting the CAPTCHA Validation Result as JSON

If you prefer to handle the Ajax client-side workflow of Captcha validation yourself, you can make an Ajax request to the BotDetect Captcha handler validation end-point Url, available through the ValidationUrl property of the BotDetect client-side object.

For example, if you make an Ajax GET request to

FormCaptcha.ValidationUrl + "&i=" + userCaptchaCodeInput // TODO: read input

you will get the Captcha validation result as a simple true or false JSON value.

Partially Submitting the Form to Validate the CAPTCHA

If you prefer a custom Ajax implementation that submits the user Captcha code input to a custom end-point in your server-side ASP.NET code, you just need to ensure that you submit the CaptchaId and InstanceId values (available as Id and InstanceId properties of the BotDetect client-side object) along with the user input.

You can then get the Captcha validation result by passing these extra parameters to the static Validate() method of the BotDetect.Web.CaptchaControl class:

// TODO: add these values to the Ajax request on the client-side
string userInput = Request.Params["userInput"] as string;
string captchaId = Request.Params["captchaId"] as string;
string instanceId = Request.Params["instanceId"] as string;

bool isHuman = BotDetect.Web.Captcha.Validate(captchaId, userInput, 
  instanceId);

A variant of this approach to Ajax Captcha validation is shown in the ASP.NET MVC jQuery Ajax Captcha code example.