BotDetect ASP.NET CAPTCHA Web MVC API Reference

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.Mvc.dll so referencing BotDetect doesn't cause a dependency on ASP.NET MVC, unless BotDetect.Web.Mvc.dll is also referenced.

BotDetect.Web.Mvc.MvcCaptcha

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

BotDetect.Web.Mvc.MvcCaptcha Class Reference
BotDetect.Web.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.Mvc.MvcCaptcha public property string UserInputID 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.Mvc.MvcCaptcha public property int CodeLength Length (number of characters) of the Captcha code rendered; the default value is 5
BotDetect.Web.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.Mvc.MvcCaptcha public property string DisallowedCodeSubstringsCsv Strings that should never occur in randomly generated Captcha codes. Can be both single characters (allows Captcha character set customization) and sequences of two or more characters (useful for swear words filtering, avoiding particular hard-to-read sequences etc.)
BotDetect.Web.Mvc.MvcCaptcha public property List<string> DisallowedCodeSubstringsList Strings that should never occur in randomly generated Captcha codes. Can be both single characters (allows Captcha character set customization) and sequences of two or more characters (useful for swear words filtering, avoiding particular hard-to-read sequences etc.)
BotDetect.Web.Mvc.MvcCaptcha public property int CodeTimeout The time period after random Captcha code generation during which Captcha challenges based on it can be solved: when it expires, even correct inputs will be considered as invalid submissions
BotDetect.Web.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.Mvc.MvcCaptcha public property System.Drawing.Size ImageSize Size of the Captcha image rendered; the default size is (250, 50)
BotDetect.Web.Mvc.MvcCaptcha public property BotDetect.ImageFormat ImageFormat Image format in which the Captcha image will be rendered; the default format is JPEG
BotDetect.Web.Mvc.MvcCaptcha public property System.Drawing.Color CustomDarkColor Optional custom dark color point, modifies the color palette used for Captcha image drawing
BotDetect.Web.Mvc.MvcCaptcha public property System.Drawing.Color CustomLightColor Optional custom light color point, modifies the color palette used for Captcha image drawing
BotDetect.Web.Mvc.MvcCaptcha public property bool SoundEnabled Is Captcha sound enabled
BotDetect.Web.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.Mvc.MvcCaptcha public property BotDetect.SoundFormat SoundFormat Audio format in which the Captcha sound will be generated; the default format is WawPcm16bit8kHzMono
BotDetect.Web.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.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.Mvc.MvcCaptcha public property string ImageTooltip The alternative text of the Captcha image Html element.
BotDetect.Web.Mvc.MvcCaptcha public property string SoundTooltip Tooltip of the Captcha sound icon.
BotDetect.Web.Mvc.MvcCaptcha public property string ReloadTooltip Tooltip of the Captcha reload icon.
BotDetect.Web.Mvc.MvcCaptcha public method string HelpLinkText Text or tooltip of the Captcha help link, depending on help link mode.
BotDetect.Web.Mvc.MvcCaptcha public method string HelpLinkUrl Url of the localized Captcha help page the help link points to.
BotDetect.Web.Mvc.MvcCaptcha public method string ReloadEnabled Is Captcha reloading (changing the Captcha code because the current one is too hard to read) enabled.
BotDetect.Web.Mvc.MvcCaptcha public property bool UseSmallIcons Default BotDetect Captcha icons are 22x22 pixels large, but there is also a smaller set of 17x17 px icons used when the default ones are too large. This settings allows you to control which icon set will be used. The default value is true when the Captcha image height is < 50px, and false otherwise
BotDetect.Web.Mvc.MvcCaptcha public property bool UseHorizontalIcons BotDetect displays the Captcha sound and reload icon one below the other by default, and switches to displaying them one beside the other when Captcha images are small enough. This setting allows you to control which BotDetect icon layout will be used. The default value is true when the Captcha image height is < 40px, and false otherwise
BotDetect.Web.Mvc.MvcCaptcha public property string SoundIconUrl Url of the optional custom Captcha sound icon that will be used instead of the default one. The default value is 'BotDetect.ashx?get=sound-icon'
BotDetect.Web.Mvc.MvcCaptcha public property string ReloadIconUrl Url of the optional custom Captcha reload icon that will be used instead of the default one. The default value is 'BotDetect.ashx?get=reload-icon'
BotDetect.Web.Mvc.MvcCaptcha public property int IconsDivWidth Custom width of the Captcha icons div element. The default value depends on Captcha image height, since BotDetect will automatically determine default icon size and position to match it
BotDetect.Web.Mvc.MvcCaptcha public property bool HelpLinkEnabled Will Captcha markup include a link to a Captcha help page providing Captcha instructions and explanations for form users. The default value is true
BotDetect.Web.Mvc.MvcCaptcha public property BotDetect.HelpLinkMode HelpLinkMode How will the Captcha help link be displayed. The default value is Text
BotDetect.Web.Mvc.MvcCaptcha public property override short TabIndex Starting tabindex for the Captcha container Html markup elements. The default value is empty (Captcha elements won't have an explicit tabindex set)
BotDetect.Web.Mvc.MvcCaptcha public property string AdditionalCssClasses User-defined CSS classes that will be added to the BotDetect CAPTCHA container <div>. The default value is empty
BotDetect.Web.Mvc.MvcCaptcha public property string AdditionalInlineCss User-defined CSS style declarations that will be added as inline style of the BotDetect CAPTCHA container <div>. The default value is empty
BotDetect.Web.Mvc.MvcCaptcha public property bool AddScriptInclude Should the BotDetect JavaScript client-side script code be included by the generated Captcha container markup. The default value is true
BotDetect.Web.Mvc.MvcCaptcha public property bool AddInitScript Should the JavaScript code for BotDetect client-side object creation be included in the generated Captcha container markup. The default value is true
BotDetect.Web.Mvc.MvcCaptcha public property bool AutoUppercaseInput Should user Captcha code input be automatically uppercased on the fly. The default value is true
BotDetect.Web.Mvc.MvcCaptcha public property bool AutoFocusInput Should the Captcha code input textbox automatically be assigned focus on all Captcha sound and Captcha reload icon clicks, allowing the users to more easily type in the code as they hear it or as the new image loads. The default value is true
BotDetect.Web.Mvc.MvcCaptcha public property bool AutoClearInput Should the Captcha user input textbox automatically be cleared on all reload icon clicks and auto-reloads of expired Captcha codes. The default value is true
BotDetect.Web.Mvc.MvcCaptcha public property bool AutoReloadExpiredCaptchas Should Captcha challenges automatically be reloaded when the Captcha code expires (controlled by the CodeTimeout property). The default value is true
BotDetect.Web.Mvc.MvcCaptcha public property int AutoReloadTimeout Time period in seconds after which automatic reloading of expired Captcha challenges will cease. The default value is 7200 seconds (2 hours)
BotDetect.Web.Mvc.MvcCaptcha public property int SoundStartDelay Starting delay (in milliseconds) of Captcha audio JavaScript playback. The default value is 0 (no delay)
BotDetect.Web.Mvc.MvcCaptcha public property bool RemoteScriptEnabled Should BotDetect also add a remote JavaScript include (remote.captcha.com/include.js) loaded from the captcha.com server (which is currently used only for stats, but is planned to develop into additional Captcha functionality). The default value is true
BotDetect.Web.MvcCaptcha public property readonly BotDetect.Web.WebCaptcha WebCaptcha Underlying Captcha instance used by the current Captcha instance. The MvcCaptcha control delegates much of it's Captcha functionality to the abstract Captcha instance
BotDetect.Web.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.Mvc.MvcCaptcha public property readonly bool IsSolved Has the current Captcha instance been successfully solved already
BotDetect.Web.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.Mvc.MvcCaptcha public method void Reset Resets the IsSolved status of the current Captcha instance
BotDetect.Web.Mvc.MvcCaptcha public method void ResetCaptcha
  • string captchaId
Resets the IsSolved status of the given Captcha
BotDetect.Web.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.Mvc.MvcCaptcha public method static bool IsCaptchaSolved
  • string captchaId
Has the given Captcha been successfully solved already
BotDetect.Web.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.Mvc.MvcCaptcha public event EventHandler <InitializedCaptcha ControlEventArgs> InitializedCaptchaControl Custom event handler delegate for InitializedCaptchaControl events, most commonly used for Captcha property randomization
BotDetect.Web.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.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.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.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.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.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.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.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.Mvc.CaptchaValidationActionFilterAttribute

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

Inherits

System.Web.Mvc.ActionFilterAttribute

BotDetect.Web.Mvc.CaptchaValidationActionFilterAttribute Class Reference
BotDetect.Web.Mvc.CaptchaValidationActionFilterAttribute public method CaptchaValidationActionFilterAttribute
  • string inputField
  • string captchaId
The default constructor takes identifiers of the Captcha code user input textbox and the Captcha control
BotDetect.Web.Mvc.CaptchaValidationActionFilterAttribute 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

BotDetect.Web.Mvc.CaptchaTagHelper

A TagHelper extension used for generating Captcha markup.

BotDetect.Web.Mvc.CaptchaTagHelper Class Reference
BotDetect.Web.Mvc.MvcCaptcha public property MvcCaptcha MvcCaptcha MvcCaptcha control instance
BotDetect.Web.Mvc.CaptchaTagHelper public method override void Process
  • Microsoft.AspNetCore.Razor.TagHelpers. TagHelperContext context
  • Microsoft.AspNetCore.Razor.TagHelpers. TagHelperOutput output
Generates Html markup for the given MvcCaptcha control instance