BotDetect ASP.NET CAPTCHA Web MVC API Reference

The BotDetet.Web.UI.Mvc encapsulates BotDetect ASP.NET Captcha Simple API types specific to ASP.NET MVC Captcha Simple API 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.MvcSimpleCaptcha

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

BotDetect.Web.Mvc.MvcSimpleCaptcha Class Reference
BotDetect.Web.Mvc.MvcSimpleCaptcha public method MvcSimpleCaptcha
  • string captchaStyleName
The constructor takes a unique identifier of the SimpleCaptcha control within the application (for example, if you placed one SimpleCaptcha control on the Registration page and another on the Contact Us, they should have distinct CaptchaStyleName values)
BotDetect.Web.Mvc.MvcSimpleCaptcha public property string UserInputID
BotDetect.Web.Mvc.MvcSimpleCaptcha public property int CodeLength Length (number of characters) of the Captcha code rendered; the default value is 5
BotDetect.Web.Mvc.MvcSimpleCaptcha public property BotDetect.CodeStyle CodeStyle Code style, i.e. the algorithm used to generate Captcha codes; the default value is Alphanumeric
BotDetect.Web.Mvc.MvcSimpleCaptcha 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.MvcSimpleCaptcha 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.MvcSimpleCaptcha public property int CodeTimeout The time period after random Captcha code generation during which SimpleCaptcha challenges based on it can be solved: when it expires, even correct inputs will be considered as invalid submissions
BotDetect.Web.Mvc.MvcSimpleCaptcha 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.MvcSimpleCaptcha public property System.Drawing.Size ImageSize Size of the Captcha image rendered; the default size is (250, 50)
BotDetect.Web.Mvc.MvcSimpleCaptcha public property BotDetect.ImageFormat ImageFormat Image format in which the Captcha image will be rendered; the default format is JPEG
BotDetect.Web.Mvc.MvcSimpleCaptcha public property System.Drawing.Color CustomDarkColor Optional custom dark color point, modifies the color palette used for Captcha image drawing
BotDetect.Web.Mvc.MvcSimpleCaptcha public property System.Drawing.Color CustomLightColor Optional custom light color point, modifies the color palette used for Captcha image drawing
BotDetect.Web.Mvc.MvcSimpleCaptcha public property bool SoundEnabled Is SimpleCaptcha sound enabled
BotDetect.Web.Mvc.MvcSimpleCaptcha 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.MvcSimpleCaptcha public property BotDetect.SoundFormat SoundFormat Audio format in which the SimpleCaptcha sound will be generated; the default format is WawPcm16bit8kHzMono
BotDetect.Web.Mvc.MvcSimpleCaptcha public property BotDetect.SoundRegenerationMode SoundRegenerationMode

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

BotDetect.Web.Mvc.MvcSimpleCaptcha public property string Locale Locale string, affects the character set used for Captcha code generation and the pronunciation language used for SimpleCaptcha sound generation
BotDetect.Web.Mvc.MvcSimpleCaptcha public property string ImageTooltip The alternative text of the Captcha image Html element.
BotDetect.Web.Mvc.MvcSimpleCaptcha public property string SoundTooltip Tooltip of the SimpleCaptcha sound icon.
BotDetect.Web.Mvc.MvcSimpleCaptcha public property string ReloadTooltip Tooltip of the SimpleCaptcha reload icon.
BotDetect.Web.Mvc.MvcSimpleCaptcha public method string HelpLinkText Text or tooltip of the SimpleCaptcha help link, depending on help link mode.
BotDetect.Web.Mvc.MvcSimpleCaptcha public method string HelpLinkUrl Url of the localized SimpleCaptcha help page the help link points to.
BotDetect.Web.Mvc.MvcSimpleCaptcha public method string ReloadEnabled Is SimpleCaptcha reloading (changing the Captcha code because the current one is too hard to read) enabled.
BotDetect.Web.Mvc.MvcSimpleCaptcha public property bool UseSmallIcons Default BotDetect SimpleCaptcha 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.MvcSimpleCaptcha public property bool UseHorizontalIcons BotDetect displays the SimpleCaptcha 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.MvcSimpleCaptcha public property string SoundIconUrl Url of the optional custom SimpleCaptcha sound icon that will be used instead of the default one. The default value is 'BotDetect.ashx?get=sound-icon'
BotDetect.Web.Mvc.MvcSimpleCaptcha public property string ReloadIconUrl Url of the optional custom SimpleCaptcha reload icon that will be used instead of the default one. The default value is 'BotDetect.ashx?get=reload-icon'
BotDetect.Web.Mvc.MvcSimpleCaptcha public property int IconsDivWidth Custom width of the SimpleCaptcha 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.MvcSimpleCaptcha public property bool HelpLinkEnabled Will SimpleCaptcha markup include a link to a SimpleCaptcha help page providing SimpleCaptcha instructions and explanations for form users. The default value is true
BotDetect.Web.Mvc.MvcSimpleCaptcha public property BotDetect.HelpLinkMode HelpLinkMode How will the SimpleCaptcha help link be displayed. The default value is Text
BotDetect.Web.Mvc.MvcSimpleCaptcha public property override short TabIndex Starting tabindex for the SimpleCaptcha container Html markup elements. The default value is empty (SimpleCaptcha elements won't have an explicit tabindex set)
BotDetect.Web.Mvc.MvcSimpleCaptcha 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.MvcSimpleCaptcha 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.MvcSimpleCaptcha public property bool AddScriptInclude Should the BotDetect JavaScript client-side script code be included by the generated SimpleCaptcha container markup. The default value is true
BotDetect.Web.Mvc.MvcSimpleCaptcha public property bool AutoUppercaseInput Should user Captcha code input be automatically uppercased on the fly. The default value is true
BotDetect.Web.Mvc.MvcSimpleCaptcha public property bool AutoFocusInput Should the Captcha code input textbox automatically be assigned focus on all SimpleCaptcha sound and SimpleCaptcha 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.MvcSimpleCaptcha public property bool AutoClearInput Should the SimpleCaptcha 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.MvcSimpleCaptcha public property bool AutoReloadExpiredCaptchas Should SimpleCaptcha challenges automatically be reloaded when the Captcha code expires (controlled by the CodeTimeout property). The default value is true
BotDetect.Web.Mvc.MvcSimpleCaptcha public property int AutoReloadTimeout Time period in seconds after which automatic reloading of expired SimpleCaptcha challenges will cease. The default value is 7200 seconds (2 hours)
BotDetect.Web.Mvc.MvcSimpleCaptcha public property int SoundStartDelay Starting delay (in milliseconds) of SimpleCaptcha audio JavaScript playback. The default value is 0 (no delay)
BotDetect.Web.Mvc.MvcSimpleCaptcha 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 SimpleCaptcha functionality). The default value is true
BotDetect.Web.MvcSimpleCaptcha public property readonly BotDetect.Web.WebCaptcha WebCaptcha Underlying SimpleCaptcha instance used by the current SimpleCaptcha instance. The MvcSimpleCaptcha control delegates much of it's SimpleCaptcha functionality to the abstract SimpleCaptcha instance
BotDetect.Web.Mvc.MvcSimpleCaptcha public property readonly string CaptchaStyleName Unique identifier of the SimpleCaptcha control within the application (for example, if you placed one SimpleCaptcha control on the Registration page and another on the Contact Us, they would have distinct CaptchaStyleName values)
BotDetect.Web.Mvc.MvcSimpleCaptcha public property readonly string CurrentCaptchaId Globally unique identifier of the current SimpleCaptcha 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.MvcSimpleCaptcha public method bool Validate
  • string userInput
  • string validatingCaptchaId
Compares the given user input with the Captcha code stored on the server for the specified captchaId
BotDetect.Web.Mvc.MvcSimpleCaptcha public method static bool Validate
  • string captchaStyleName
  • string userInput
  • string captchaId
Validate the SimpleCaptcha from a server-side call, specifying all validation parameters. Used in cases when a CaptchaControl instance is not available
BotDetect.Web.Mvc.MvcSimpleCaptcha public event EventHandler <InitializedSimpleCaptcha ControlEventArgs> InitializedCaptchaControl Custom event handler delegate for InitializedCaptchaControl events, most commonly used for SimpleCaptcha property randomization
BotDetect.Web.Mvc.MvcSimpleCaptcha public event EventHandler <GeneratingSimpleCaptcha CodeEventArgs> GeneratingCaptchaCode Custom event handler delegate for GeneratingCaptchaCode events, which occur before each Captcha code is generated
BotDetect.Web.Mvc.MvcSimpleCaptcha public event EventHandler <GeneratedSimpleCaptcha CodeEventArgs> GeneratedCaptchaCode Custom event handler delegate for GeneratedCaptchaCode events, which occur after each Captcha code has been generated
BotDetect.Web.Mvc.MvcSimpleCaptcha public event EventHandler <GeneratingSimpleCaptcha ImageEventArgs> GeneratingCaptchaImage Custom event handler delegate for GeneratingCaptchaImage events, which occur before each Captcha image is generated
BotDetect.Web.Mvc.MvcSimpleCaptcha public event EventHandler <GeneratedSimpleCaptcha ImageEventArgs> GeneratedCaptchaImage Custom event handler delegate for GeneratedCaptchaImage events, which occur after each Captcha image has been generated
BotDetect.Web.Mvc.MvcSimpleCaptcha public event EventHandler <GeneratingSimpleCaptcha SoundEventArgs> GeneratingCaptchaSound Custom event handler delegate for GeneratingCaptchaSound events, which occur before each SimpleCaptcha sound is generated
BotDetect.Web.Mvc.MvcSimpleCaptcha public event EventHandler <GeneratedSimpleCaptcha SoundEventArgs> GeneratedCaptchaSound Custom event handler delegate for GeneratedCaptchaSound events, which occur after each SimpleCaptcha sound has been generated
BotDetect.Web.Mvc.MvcSimpleCaptcha public event EventHandler <SimpleValidatingUser InputEventArgs> ValidatingUserInput Custom event handler delegate for ValidatingUserInput events, which occur before each user input is generated
BotDetect.Web.Mvc.MvcSimpleCaptcha public event EventHandler <SimpleValidatedUser InputEventArgs> ValidatedUserInput Custom event handler delegate for ValidatedUserInput events, which occur after each user input has been generated

BotDetect.Web.Mvc.SimpleCaptchaValidationAttribute

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

Inherits

System.Web.Mvc.ActionFilterAttribute

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

BotDetect.Web.Mvc.SimpleCaptchaHtmlHelper

A HtmlHelper extension used for generating SimpleCaptcha markup.

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

BotDetect.Web.Mvc.SimpleCaptchaTagHelper

A TagHelper extension used for generating SimpleCaptcha markup.

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