BotDetect ASP.NET CAPTCHA Web MVC API Reference (BotDetect v3.0; deprecated)

The BotDetet.Web.UI.Mvc encapsulates BotDetect ASP.NET Captcha 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

A BotDetect Captcha control variant used for ASP.NET MVC applications.

BotDetect.Web.UI.Mvc.MvcCaptcha Class Reference
BotDetect.Web.UI.Mvc.MvcCaptcha public method MvcCaptcha
  • string captchaId
The constructor takes a unique identifier of the Captcha control within the application (for example, if you placed one Captcha control on the Registration page and another on the Contact Us, they should have distinct CaptchaId values)
BotDetect.Web.UI.Mvc.MvcCaptcha public method bool Validate
  • string userInput
  • string validatingInstanceId
Compares the given user input with the Captcha code stored on the server for the specified instanceId
BotDetect.Web.UI.Mvc.MvcCaptcha public method void SaveSettings Saves Captcha settings to the Captcha persistence provider. Has to be called explicitly in ASP.NET MVC applications, since there is no equivalent of the Page_PreRender event in which this can be done automatically
BotDetect.Web.UI.Mvc.MvcCaptcha public method void Reset Resets the IsSolved status of the current Captcha instance
BotDetect.Web.UI.Mvc.MvcCaptcha public property string UserInputClientID User input textbox client-side identifier (the ASP.NET ClientID property), used for all client-side user input processing, e.g. automatic user input lowercasing and focusing
BotDetect.Web.UI.Mvc.MvcCaptcha public property string Locale Locale string, affects the character set used for Captcha code generation and the pronunciation language used for Captcha sound generation
BotDetect.Web.UI.Mvc.MvcCaptcha public property int CodeLength Length (number of characters) of the Captcha code rendered; the default value is 5
BotDetect.Web.UI.Mvc.MvcCaptcha public property BotDetect.CodeStyle CodeStyle Code style, i.e. the algorithm used to generate Captcha codes; the default value is Alphanumeric
BotDetect.Web.UI.Mvc.MvcCaptcha public property string CustomCharacterSetName Optional name of the user-defined character set used for Captcha code generation. A collection of custom character sets can be defined in the <botDetect> section of the web.config file
BotDetect.Web.UI.Mvc.MvcCaptcha public property BotDetect.ImageStyle ImageStyle Image style, i.e. the algorithm used to render Captcha codes in images; if no image style is set, it is randomized by default
BotDetect.Web.UI.Mvc.MvcCaptcha public property System.Drawing.Size ImageSize Size of the Captcha image rendered; the default size is (250, 50)
BotDetect.Web.UI.Mvc.MvcCaptcha public property BotDetect.ImageFormat ImageFormat Image format in which the Captcha image will be rendered; the default format is JPEG
BotDetect.Web.UI.Mvc.MvcCaptcha public property System.Drawing.Color CustomDarkColor Optional custom dark color point, modifies the color palette used for Captcha image drawing
BotDetect.Web.UI.Mvc.MvcCaptcha public property System.Drawing.Color CustomLightColor Optional custom light color point, modifies the color palette used for Captcha image drawing
BotDetect.Web.UI.Mvc.MvcCaptcha public property BotDetect.SoundStyle SoundStyle Sound style, i.e. the algorithm used to pronounce Captcha codes in sounds; if no sound style is set, it is randomized by default
BotDetect.Web.UI.Mvc.MvcCaptcha public property BotDetect.SoundFormat SoundFormat Audio format in which the Captcha sound will be generated; the default format is WawPcm16bit8kHzMono
BotDetect.Web.UI.Mvc.MvcCaptcha public property BotDetect.SoundRegenerationMode SoundRegenerationMode

Sound regeneration mode determining how will multiple consecutive requests for audio Captcha with the same Captcha code be handled by BotDetect; the default mode is Limited.

BotDetect.Web.UI.Mvc.MvcCaptcha public property string CaptchaImageTooltip The Captcha image tooltip can be set for the entire application using web.config settings; this instance property allows overriding those values dynamically.
BotDetect.Web.UI.Mvc.MvcCaptcha public property string ReloadIconTooltip The Captcha reload icon tooltip can be set for the entire application using web.config settings; this instance property allows overriding those values dynamically.
BotDetect.Web.UI.Mvc.MvcCaptcha public property string SoundIconTooltip The Captcha sound icon tooltip can be set for the entire application using web.config settings; this instance property allows overriding those values dynamically.
BotDetect.Web.UI.Mvc.MvcCaptcha public property bool UseHorizontalIcons By default, tells is the selected Captcha image height so low that we should switch to horizontal icon rendering; can be user-specified to always (or never) switch to the horizontal icon layout
BotDetect.Web.UI.Mvc.MvcCaptcha public property bool UseSmallIcons By default, tells is the selected Captcha image height so low that we should switch to smaller icons; can be user-specified to always (or never) use small icons
BotDetect.Web.UI.Mvc.MvcCaptcha public property int IconsDivWidth Calculated width of the Captcha icons <div>, can be user-set to create custom icon layouts
BotDetect.Web.UI.Mvc.MvcCaptcha public property short TabIndex

Starting tabindex for the Captcha control Html output.

The keyboard-selectable Captcha markup elements are: the Captcha reload icon, the Captcha sound icon, and (only in the Free version of BotDetect) the BotDetect website link.

Depending on your settings (is Captcha reloading enabled, are Captcha sounds enabled) and the version of BotDetect you are using (free or paid), the next available tabindex on the page can be from 0 to 3 greater than this value.
BotDetect.Web.UI.MvcCaptcha public property readonly BotDetect.Web. CaptchaControl CaptchaControl Underlying CaptchaControl instance used by the current Captcha instance. The MvcCaptcha control delegates much of it's Captcha functionality to the abstract CaptchaControl instance
BotDetect.Web.UI.Mvc.MvcCaptcha public property readonly string CaptchaId Unique identifier of the Captcha control within the application (for example, if you placed one Captcha control on the Registration page and another on the Contact Us, they would have distinct CaptchaId values)
BotDetect.Web.UI.Mvc.MvcCaptcha public property readonly bool IsSolved Has the current Captcha instance been successfully solved already
BotDetect.Web.UI.Mvc.MvcCaptcha public property readonly string CurrentInstanceId Globally unique identifier of the current Captcha object instance, used to ensure each page load keeps separate Captcha codes, for example when opening the same form in multiple browser tabs
BotDetect.Web.UI.Mvc.MvcCaptcha public event EventHandler <InitializedCaptcha ControlEventArgs> InitializedCaptchaControl Custom event handler delegate for InitializedCaptchaControl events, most commonly used for Captcha property randomization
BotDetect.Web.UI.Mvc.MvcCaptcha public event EventHandler <GeneratingCaptcha CodeEventArgs> GeneratingCaptchaCode Custom event handler delegate for GeneratingCaptchaCode events, which occur before each Captcha code is generated
BotDetect.Web.UI.Mvc.MvcCaptcha public event EventHandler <GeneratedCaptcha CodeEventArgs> GeneratedCaptchaCode Custom event handler delegate for GeneratedCaptchaCode events, which occur after each Captcha code has been generated
BotDetect.Web.UI.Mvc.MvcCaptcha public event EventHandler <GeneratingCaptcha ImageEventArgs> GeneratingCaptchaImage Custom event handler delegate for GeneratingCaptchaImage events, which occur before each Captcha image is generated
BotDetect.Web.UI.Mvc.MvcCaptcha public event EventHandler <GeneratedCaptcha ImageEventArgs> GeneratedCaptchaImage Custom event handler delegate for GeneratedCaptchaImage events, which occur after each Captcha image has been generated
BotDetect.Web.UI.Mvc.MvcCaptcha public event EventHandler <GeneratingCaptcha SoundEventArgs> GeneratingCaptchaSound Custom event handler delegate for GeneratingCaptchaSound events, which occur before each Captcha sound is generated
BotDetect.Web.UI.Mvc.MvcCaptcha public event EventHandler <GeneratedCaptcha SoundEventArgs> GeneratedCaptchaSound Custom event handler delegate for GeneratedCaptchaSound events, which occur after each Captcha sound has been generated
BotDetect.Web.UI.Mvc.MvcCaptcha public event EventHandler <ValidatingUser InputEventArgs> ValidatingUserInput Custom event handler delegate for ValidatingUserInput events, which occur before each user input is generated
BotDetect.Web.UI.Mvc.MvcCaptcha public event EventHandler <ValidatedUser InputEventArgs> ValidatedUserInput Custom event handler delegate for ValidatedUserInput events, which occur after each user input has been generated
BotDetect.Web.UI.Mvc.MvcCaptcha public method static bool Validate
  • string captchaId
  • string userInput
  • string instanceId
Validate the Captcha from a server-side call, specifying all validation parameters. Used in cases when a CaptchaControl instance is not available
BotDetect.Web.UI.Mvc.MvcCaptcha public property static System.Collections. Generic.List<string> BannedSequences Optional global list of sequences which will be filtered out of the randomly generated Captcha codes, used for example for swear-word filtering

BotDetect.Web.UI.Mvc.CaptchaValidationAttribute

An ActionFilterAttribute sub-class setting RouteData depending on the Captcha validation result.

Inherits

System.Web.Mvc.ActionFilterAttribute

BotDetect.Web.UI.Mvc.CaptchaValidationAttribute Class Reference
BotDetect.Web.UI.Mvc.CaptchaValidationAttribute public method CaptchaValidationAttribute
  • string inputField
  • string captchaId
The default constructor takes identifiers of the Captcha code user input textbox and the Captcha control
BotDetect.Web.UI.Mvc.CaptchaValidationAttribute public method void OnActionExecuting
  • System.Web.Mvc. ActionExecutingContext filterContext
ActionFilterAttribute override, validating the submitted Captcha code input and setting RouteData accordingly

BotDetect.Web.Mvc.CaptchaHtmlHelper

A HtmlHelper extension used for generating Captcha markup.

BotDetect.Web.Mvc.CaptchaHtmlHelper Class Reference
BotDetect.Web.Mvc.CaptchaHtmlHelper public method static string Captcha
  • this System.Web.Mvc. HtmlHelper helper
  • object captchaInstance
Generates Html markup for the given MvcCaptcha control instance

Please Note

The information on this page is out of date and applies to a deprecated version of BotDetect™ CAPTCHA (v3.0).

An up-to-date equivalent page for the latest BotDetect Captcha release (v4) is BotDetect v4 Captcha documentation index.

General information about the major improvements in the current BotDetect release can be found at the What's New in BotDetect v4.0 page.