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 class
- BotDetect.Web.Mvc.CaptchaValidationActionFilterAttribute class
- BotDetect.Web.Mvc.CaptchaHtmlHelper class
- BotDetect.Web.Mvc.CaptchaTagHelper class
BotDetect.Web.Mvc.MvcCaptcha
A BotDetect Captcha control variant used for ASP.NET MVC applications.
BotDetect.Web.Mvc.MvcCaptcha Class Reference | ||
---|---|---|
MvcCaptcha
|
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) | |
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 | |
int CodeLength | Length (number of characters) of the Captcha code rendered; the default value is 5 | |
BotDetect.CodeStyle CodeStyle | Code style, i.e. the algorithm used to generate Captcha codes; the default value is Alphanumeric | |
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.) | |
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.) | |
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.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 | |
System.Drawing.Size ImageSize | Size of the Captcha image rendered; the default size is (250, 50) | |
BotDetect.ImageFormat ImageFormat | Image format in which the Captcha image will be rendered; the default format is JPEG | |
System.Drawing.Color CustomDarkColor | Optional custom dark color point, modifies the color palette used for Captcha image drawing | |
System.Drawing.Color CustomLightColor | Optional custom light color point, modifies the color palette used for Captcha image drawing | |
bool SoundEnabled | Is Captcha sound enabled | |
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.SoundFormat SoundFormat | Audio format in which the Captcha sound will be generated; the default format is WawPcm16bit8kHzMono | |
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 |
|
string Locale | Locale string, affects the character set used for Captcha code generation and the pronunciation language used for Captcha sound generation | |
string ImageTooltip | The alternative text of the Captcha image Html element. | |
string SoundTooltip | Tooltip of the Captcha sound icon. | |
string ReloadTooltip | Tooltip of the Captcha reload icon. | |
string HelpLinkText | Text or tooltip of the Captcha help link, depending on help link mode. | |
string HelpLinkUrl | Url of the localized Captcha help page the help link points to. | |
string ReloadEnabled | Is Captcha reloading (changing the Captcha code because the current one is too hard to read) enabled. | |
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 | |
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 | |
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' | |
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' | |
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 | |
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.HelpLinkMode HelpLinkMode | How will the Captcha help link be displayed. The default value is Text | |
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) | |
string AdditionalCssClasses | User-defined CSS classes that will be added to the BotDetect CAPTCHA container <div>. The default value is empty | |
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 | |
bool AddScriptInclude | Should the BotDetect JavaScript client-side script code be included by the generated Captcha container markup. The default value is true | |
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 | |
bool AutoUppercaseInput | Should user Captcha code input be automatically uppercased on the fly. The default value is true | |
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 | |
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 | |
bool AutoReloadExpiredCaptchas | Should Captcha challenges automatically be reloaded when the Captcha code expires (controlled by the CodeTimeout property). The default value is true | |
int AutoReloadTimeout | Time period in seconds after which automatic reloading of expired Captcha challenges will cease. The default value is 7200 seconds (2 hours) | |
int SoundStartDelay | Starting delay (in milliseconds) of Captcha audio JavaScript playback. The default value is 0 (no delay) | |
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 | |
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 | |
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) | |
readonly bool IsSolved | Has the current Captcha instance been successfully solved already | |
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 | |
void Reset | Resets the IsSolved status of the current Captcha instance | |
void ResetCaptcha
|
Resets the IsSolved status of the given Captcha | |
bool Validate
|
Compares the given user input with the Captcha code stored on the server for the specified instanceId | |
static bool IsCaptchaSolved
|
Has the given Captcha been successfully solved already | |
static bool Validate
|
Validate the Captcha from a server-side call, specifying all validation parameters. Used in cases when a CaptchaControl instance is not available | |
EventHandler <InitializedCaptcha ControlEventArgs> InitializedCaptchaControl | Custom event handler delegate for InitializedCaptchaControl events, most commonly used for Captcha property randomization | |
EventHandler <GeneratingCaptcha CodeEventArgs> GeneratingCaptchaCode | Custom event handler delegate for GeneratingCaptchaCode events, which occur before each Captcha code is generated | |
EventHandler <GeneratedCaptcha CodeEventArgs> GeneratedCaptchaCode | Custom event handler delegate for GeneratedCaptchaCode events, which occur after each Captcha code has been generated | |
EventHandler <GeneratingCaptcha ImageEventArgs> GeneratingCaptchaImage | Custom event handler delegate for GeneratingCaptchaImage events, which occur before each Captcha image is generated | |
EventHandler <GeneratedCaptcha ImageEventArgs> GeneratedCaptchaImage | Custom event handler delegate for GeneratedCaptchaImage events, which occur after each Captcha image has been generated | |
EventHandler <GeneratingCaptcha SoundEventArgs> GeneratingCaptchaSound | Custom event handler delegate for GeneratingCaptchaSound events, which occur before each Captcha sound is generated | |
EventHandler <GeneratedCaptcha SoundEventArgs> GeneratedCaptchaSound | Custom event handler delegate for GeneratedCaptchaSound events, which occur after each Captcha sound has been generated | |
EventHandler <ValidatingUser InputEventArgs> ValidatingUserInput | Custom event handler delegate for ValidatingUserInput events, which occur before each user input is generated | |
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 | ||
---|---|---|
CaptchaValidationActionFilterAttribute
|
The default constructor takes identifiers of the Captcha code user input textbox and the Captcha control | |
void OnActionExecuting
|
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 | ||
---|---|---|
static string Captcha
|
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 | ||
---|---|---|
MvcCaptcha MvcCaptcha | MvcCaptcha control instance | |
override void Process
|
Generates Html markup for the given MvcCaptcha control instance |
Current BotDetect Versions
-
BotDetect ASP.NET CAPTCHA
2019-07-22v4.4.2 -
BotDetect Java CAPTCHA
2019-07-22v4.0.Beta3.7 -
BotDetect PHP CAPTCHA
2019-07-22v4.2.5