BotDetect MVC CAPTCHA Documentation
This page is an index of BotDetect Captcha documentation regarding MVC Captcha integration and validation, listing code samples, how to guides, the BotDetect MVC API reference and implementation options available in different versions of BotDetect and various supported MVC frameworks.
MVC CAPTCHA in PHP
CakePHP MVC CAPTCHA
CakePHP MVC CAPTCHA How To Guide
Adding BotDetect PHP Captcha protection to your CakePHP MVC applications requires a slightly different approach than adding it to basic PHP websites, but is still straightforward. This page will guide you through the necessary steps and explain the available options.
- Include BotDetect in your CakePHP application
- Display BotDetect in your CakePHP View
- Validate the Captcha in your CakePHP Controller
CakePHP MVC CAPTCHA Basic Sample
This sample illustrates the most basic form of BotDetect PHP Captcha protection in CakePHP MVC applications.
Alongside the Captcha image, the user is provided with an input field to retype the displayed characters. Depending on if the Captcha code entered matches the displayed one or not, a message stating the validation result is shown on the form.
The simple code showing the message in this sample would of course be replaced with useful form processing code in a real world scenario.
| Default Source Code Folder | Online Source |
|---|---|
| Part of the BotDetect Captcha CakePHP integration package |
CakePHP MVC CAPTCHA Form Validation Sample
This sample shows how to integrate BotDetect PHP Captcha validation and CakePHP data validation functionality. It uses Cake's FormHelper and Model validation, which provide a lot of out-the-box functionality when used together.
The sample is based around a contact form which sends email if the user input is considered valid – a likely real world scenario for Captcha protection integration.
To keep the sample brief, it doesn't use a database backend. Still, this type of Model integration is ideal for protecting database-driven forms that take advantage of the CakePHP Model infrastructure.
| Default Source Code Folder | Online Source |
|---|---|
| Part of the BotDetect Captcha CakePHP integration package |
CodeIgniter MVC CAPTCHA
CodeIgniter MVC CAPTCHA How To Guide
Adding BotDetect PHP Captcha protection to your CodeIgniter MVC applications requires a slightly different approach than adding it to basic PHP websites, but is still straightforward. This page will guide you through the necessary steps and explain the available options.
- Include BotDetect in your CodeIgniter application
- Display BotDetect in your CodeIgniter View
- Validate the Captcha in your CodeIgniter Controller
CodeIgniter MVC CAPTCHA Basic Sample
This sample illustrates the most basic form of BotDetect PHP Captcha protection in CodeIgniter MVC applications.
Alongside the Captcha image, the user is provided with an input field to retype the displayed characters. Depending on if the Captcha code entered matches the displayed one or not, a message stating the validation result is shown on the form.
The simple code showing the message in this sample would of course be replaced with useful form processing code in a real world scenario.
| Default Source Code Folder | Online Source |
|---|---|
| Part of the BotDetect Captcha CodeIgniter integration package |
CodeIgniter MVC CAPTCHA Form Validation Sample
This sample shows how to integrate BotDetect PHP Captcha validation and CodeIgniter form validation functionality. It uses the CodeIgniter Form helper and the Form Validation library.
The brief sample is based around a contact form which sends email if the user input is considered valid – a likely real world scenario for Captcha protection integration.
| Default Source Code Folder | Online Source |
|---|---|
| Part of the BotDetect Captcha CodeIgniter integration package |
MVC CAPTCHA in ASP.NET
ASP.NET MVC CAPTCHA Integration How To Guide
BotDetect ASP.NET Captcha protection can be added to your ASP.NET MVC applications using the MvcCaptcha class, a BotDetect HtmlHelper and a custom ActionFilterAttribute implemented in the BotDetect.Web.UI.Mvc.dll assembly.
- Display a Captcha challenge on the Asp.Net MVC View
- Check is the visitor a human in the Controller action
ASP.NET MVC Basic CAPTCHA Sample
The ASP.NET MVC Basic Captcha sample project shows the most basic source code required to protect an ASP.NET MVC form with BotDetect CAPTCHA and validate the user input.
ASP.NET MVC View code displaying CAPTCHA protection can be found in Views/Sample/Index.aspx, and the ASP.NET MVC Controller code checking user input is in Controllers/SampleController.vb.
| ASP.NET MVC | Default Source Code Folder | Online Source |
|---|---|---|
| ASP.NET MVC 4.0 | C:\Program Files\Lanapsoft\BotDetect 3 CAPTCHA Component\Asp.Net\v4.5\WebApp\ AspNetMvc40BasicCaptchaSample |
ASP.NET MVC Internet Application CAPTCHA Sample
This sample project shows how to use the BotDetect MvcCaptcha control in ASP.NET MVC web applications.
Starting with the default ASP.NET MVC sample project, the sample includes all code required to add Captcha validation to the Account controller Register action.
| ASP.NET MVC | Default Source Code Folder | Online Source |
|---|---|---|
| ASP.NET MVC 4.0 | C:\Program Files\Lanapsoft\BotDetect 3 CAPTCHA Component\Asp.Net\v4.5\WebApp\ AspNetMvc40CaptchaSample | |
| ASP.NET MVC 3.0 | C:\Program Files\Lanapsoft\BotDetect 3 CAPTCHA Component\Asp.Net\v4.0\WebApp\ AspNetMvc30CaptchaSample | |
| ASP.NET MVC 2.0 | C:\Program Files\Lanapsoft\BotDetect 3 CAPTCHA Component\Asp.Net\v4.0\WebApp\ AspNetMvc20CaptchaSample and C:\Program Files\Lanapsoft\BotDetect 3 CAPTCHA Component\Asp.Net\v3.5\WebApp\ AspNetMvc20CaptchaSample |
|
| ASP.NET MVC 1.0 | C:\Program Files\Lanapsoft\BotDetect 3 CAPTCHA Component\Asp.Net\v3.5\WebApp\ AspNetMvc10CaptchaSample |
ASP.NET MVC jQuery Ajax CAPTCHA Sample
The ASP.NET MVC 4.0 jQuery Ajax Captcha VB.NET ASPX sample project shows how to perform Ajax Captcha validation using a jQuery $.getJSON call on the client combined with an ASP.NET MVC 4.0 JsonResult Controller action on the server.
Both the client-side code (located in Scripts\CheckCaptcha.js) and the server-side code (Controllers\SampleController.vb) are very simple, and allow BotDetect Captcha protection to be added in a variety of custom Ajax forms and scenarios.
| ASP.NET MVC | Default Source Code Folder | Online Source |
|---|---|---|
| ASP.NET MVC 4.0 | C:\Program Files\Lanapsoft\BotDetect 3 CAPTCHA Component\Asp.Net\v4.5\WebApp\ AspNetMvc40AjaxCaptchaSample |
BotDetect.Web.UI.Mvc ASP.NET CAPTCHA Reference
The BotDetect.Web.UI.Mvc namespace encapsulates BotDetect types specific to ASP.NET MVC Captcha implementations. It's separated from the main BotDetect assembly into BotDetect.Web.UI.Mvc.dll so referencing BotDetect doesn't cause a dependency on ASP.NET MVC (unless BotDetect.Web.UI.Mvc.dll is also referenced).
BotDetect.Web.UI.Mvc.MvcCaptcha Class Reference
A BotDetect Captcha control variant used for ASP.NET MVC applications.
Read the full BotDetect.Web.UI.Mvc.MvcCaptcha class API reference...
BotDetect.Web.UI.Mvc.CaptchaValidationAttribute Class Reference
An ActionFilterAttribute sub-class setting RouteData depending on the Captcha validation result.
Read the full BotDetect.Web.UI.Mvc.CaptchaValidationAttribute class API reference...
System.Web.Mvc.CaptchaHtmlHelper Class Reference
A HtmlHelper extension used for generating Captcha markup.
Read the full System.Web.Mvc.CaptchaHtmlHelper class API reference...
ASP.NET MVC CAPTCHA FAQ
ASP.NET MVC Version Compatibility
I'm trying to add BotDetect to my ASP.NET MVC application, but I'm getting "Could not load file or assembly 'System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference." errors when I try to run it. Your component seems to be referencing an older version of ASP.NET MVC, which is not installed on my system.
ASP.NET MVC No Captcha Code Model Field
Your ASP.NET MVC integration instructions start by adding a CaptchaCode field to a Model class, which conflicts with our requirements. Can we add BotDetect Captcha protection to a Controller action without adding any fields to the Model declarations?
ASP.NET MVC Resource-Based Error Message Localization
How do I use localized Captcha validation error messages from ASP.NET MVC application resources? If I use [CaptchaValidation("Captcha", "RegistrationCaptcha", Resources.Error.CaptchaMismatch)], I get "An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type" errors.
Current BotDetect Versions
- BotDetect PHP CAPTCHA v3.0.Beta12013 May 20
- BotDetect ASP.NET CAPTCHA v3.0.142013 May 20
- BotDetect ASP Classic CAPTCHA v3.0.142013 May 20



