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

While the BotDetect.Web members are used for Captcha control functionality within a Web context, the root BotDetect ASP.NET Captcha namespace contains members related to general Captcha functionality, independent of the context it's used for.

BotDetect.CaptchaBase

A base Captcha object, representing a generic Captcha instance capable of generating Captcha codes, images and sounds + validating user inputs. The CaptchaControl instances tailored for System.Web use all delegate core Captcha functionality to a contained CaptchaBase instance.

Also, if you were for example implementing a Captcha class tailored for Windows Forms applications, you would implement a CaptchaWinFormControl class, which would implement desktop context-specific functionality and delegate Captcha functionality to a contained CaptchaBase instance.

BotDetect.CaptchaBase Class Reference
BotDetect.CaptchaBase public method CaptchaBase
  • string captchaId
Captcha identifier, distinguishing multiple Captcha instances within the system. Each Captcha used in a different location (web page or Windows Form or mobile screen) must have a unique identifier
BotDetect.CaptchaBase public method string GetCode
  • string instanceId
  • BotDetect. CodeGenerationPurpose purpose
Generates a random Captcha code for the given purpose, using settings stored in instance data belonging to the specified instanceId
BotDetect.CaptchaBase public method System.IO.MemoryStream GetImage
  • string instanceId
Generates a Captcha image, using settings stored in instance data belonging to the specified instanceId
BotDetect.CaptchaBase public method System.IO.MemoryStream GetSound
  • string instanceId
Generates a Captcha sound, using settings stored in instance data belonging to the specified instanceId
BotDetect.CaptchaBase public method bool Validate
  • string userInput
  • string instanceId
  • BotDetect. ValidationAttemptOrigin origin
Compares the user input to the Captcha code stored for the given instanceId, using validation rules specified for the current ValidationAttemptOrigin
BotDetect.CaptchaBase public property string CaptchaId Captcha identifier, distinguishing multiple Captcha instances within the system. Can also be accessed through this property, after being initialized in the constructor
BotDetect.CaptchaBase 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.CaptchaBase public property int CodeLength Length (number of characters) of the Captcha code rendered; the default value is 5
BotDetect.CaptchaBase public property BotDetect.CodeStyle CodeStyle Code style, i.e. the algorithm used to generate Captcha codes; the default value is Alphanumeric
BotDetect.CaptchaBase 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 currently used Captcha configuration provider
BotDetect.CaptchaBase 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.CaptchaBase public property BotDetect.ImageFormat ImageFormat Image format in which the Captcha image will be rendered; the default format is JPEG
BotDetect.CaptchaBase public property BotDetect.Drawing.Color CustomDarkColor Optional custom dark color point, modifies the color palette used for Captcha image drawing
BotDetect.CaptchaBase public property BotDetect.Drawing.Color CustomLightColor Optional custom light color point, modifies the color palette used for Captcha image drawing
BotDetect.CaptchaBase public property BotDetect.SoundStyle SoundStyle Sound style, i.e. the algorithm used to pronounce Captcha codes in sounds; the default image style is Dispatch
BotDetect.CaptchaBase public property BotDetect.SoundFormat SoundFormat Audio format in which the Captcha sound will be generated; the default format is WawPcm16bit8kHzMono
BotDetect.CaptchaBase 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.CaptchaBase public property readonly string InstanceId Globally unique identifier of the current CaptchaBase object instance
BotDetect.CaptchaBase public property readonly bool IsLocalized PronunciationAvailable Is the BotDetect pronunciation sound package for the currently used locale available
BotDetect.CaptchaBase public method static void RegisterGenerating CaptchaCodeHandler
  • string captchaId
  • EventHandler< BotDetect.GeneratingCaptcha CodeEventArgs> handler
Propagate GeneratingCaptchaCode event handlers registered in delegating classes to the global event delegate
BotDetect.CaptchaBase public method static void RegisterGenerated CaptchaCodeHandler
  • string captchaId
  • EventHandler< BotDetect.GeneratedCaptcha CodeEventArgs> handler
Propagate GeneratedCaptchaCode event handlers registered in delegating classes to the global event delegate
BotDetect.CaptchaBase public method static void RegisterGenerating CaptchaImageHandler
  • string captchaId
  • EventHandler< BotDetect.GeneratingCaptcha ImageEventArgs> handler
Propagate GeneratingCaptchaImage event handlers registered in delegating classes to the global event delegate
BotDetect.CaptchaBase public method static void RegisterGenerated CaptchaImageHandler
  • string captchaId
  • EventHandler< BotDetect.GeneratedCaptcha ImageEventArgs> handler
Propagate GeneratedCaptchaImage event handlers registered in delegating classes to the global event delegate
BotDetect.CaptchaBase public method static void RegisterGenerating CaptchaSoundHandler
  • string captchaId
  • EventHandler< BotDetect.GeneratingCaptcha SoundEventArgs> handler
Propagate GeneratingCaptchaSound event handlers registered in delegating classes to the global event delegate
BotDetect.CaptchaBase public method static void RegisterGenerated CaptchaSoundHandler
  • string captchaId
  • EventHandler< BotDetect.GeneratedCaptcha SoundEventArgs> handler
Propagate GeneratedCaptchaSound event handlers registered in delegating classes to the global event delegate
BotDetect.CaptchaBase public method static void RegisterValidating UserInputHandler
  • string captchaId
  • EventHandler< BotDetect.ValidatingUser InputEventArgs> handler
Propagate ValidatingUserInput event handlers registered in delegating classes to the global event delegate
BotDetect.CaptchaBase public method static void RegisterValidated UserInputHandler
  • string captchaId
  • EventHandler< BotDetect.ValidatedUser InputEventArgs> handler
Propagate ValidatedUserInput event handlers registered in delegating classes to the global event delegate
BotDetect.CaptchaBase public property static BotDetect. BannedCharacterSequences BannedCharacterSequences Optional global list of sequences which will be filtered out of the randomly generated Captcha codes, used for example for swear-word filtering. The BannedCharacterSequences object is created from the string values passed by the delegating classes
BotDetect.CaptchaBase public property static readonly System.Text. RegularExpressions.Regex ValidCaptchaId The global regular expression object used to validate CaptchaId values and ensure they match the persistence medium key limitations

BotDetect.Code

Represents a single randomly generated Captcha code.

BotDetect.Code Class Reference
BotDetect.Code public method Code
  • string captchaCode
The constructor takes the freshly generated random Captcha code that will be contained in the object
BotDetect.Code public property bool IsUsedForSoundGeneration Has the Captcha code been used to generate a Captcha sound
BotDetect.Code public property bool IsUsedForImageGeneration Has the Captcha code been used to generate a Captcha image
BotDetect.Code public property readonly string CaptchaCode The random Captcha code contained in the object
BotDetect.Code public property readonly System.DateTime GenerationTime When was the random Captcha code generated
BotDetect.Code public property readonly int ElapsedSeconds How many seconds have elapsed since the random Captcha code was generated

BotDetect.CodeCollection

Represents a collection of Captcha codes generated for a particular Captcha instance (identified by captchaId) in the current applications.

Implements

System.Collections.Generic.IEnumerable<BotDetect.Code>, System.Collections.IEnumerable

BotDetect.CodeCollection Class Reference
BotDetect.CodeCollection public method CodeCollection The default CodeCollection constructor takes no arguments
BotDetect.CodeCollection public method public IEnumerator <BotDetect.Code> GetEnumerator Allows enumerating the contained Code instances
BotDetect.CodeCollection public method string GetCode
  • string instanceId
  • BotDetect. CodeGenerationPurpose purpose
  • BotDetect.CodeStyle codeStyle
  • int codeLength
Given the Captcha instance identifier and Captcha code purpose, returns an existing Captcha code if a valid one exists, or creates a new one automatically
BotDetect.CodeCollection public method void SaveCode
  • string instanceId
  • BotDetect.Code code
  • int timeLimit
Stores a Code object in the collection
BotDetect.CodeCollection public method bool Validate
  • string userInput
  • string instanceId
  • BotDetect. ValidationAttemptOrigin origin
Compares the user input to stored values matching the criteria
BotDetect.CodeCollection public property readonly int Count How many Code instances are contained in the collection
BotDetect.CodeCollection public property readonly static int CodeTimeout The currently configured timeout used to invalidate Captcha codes after a certain period of time

BotDetect.BannedCharacterSequences

Represents a collection of banned character sequences that will be excluded from all randomly generated Captcha codes.

BotDetect.BannedCharacterSequences Class Reference
BotDetect.BannedCharacterSequences public method BannedCharacterSequences
  • System.Collections. Generic.List<string> input
The default BannedCharacterSequences constructor takes a list of banned sequences as simple strings
BotDetect.BannedCharacterSequences public method BotDetect.Set<int> GetBannedCharacters Returns the full set of individual banned Unicode code points (which can also be specified this way)
BotDetect.BannedCharacterSequences public method BotDetect.Set<int> GetBannedCharacters
  • int length
  • string startingWith
Returns the set of possible Unicode code points that must not be used to randomly choose the next character, given the current already generated character sequence

BotDetect.CaptchaRandomization

A helper class used for easy randomization of Captcha parameters.

BotDetect.CaptchaRandomization Class Reference
BotDetect.CaptchaRandomization public method static int GetRandomCodeLength Returns a random Captcha code length, using default code length bounds
BotDetect.CaptchaRandomization public method static int GetRandomCodeLength
  • int max
Returns a random Captcha code length, using the default minimal value and the specified maximal value
BotDetect.CaptchaRandomization public method static int GetRandomCodeLength
  • int min
  • int max
Returns a random Captcha code length, using the specified minimal and maximal values
BotDetect.CaptchaRandomization public method static BotDetect.CodeStyle GetRandomCodeStyle
  • params BotDetect.CodeStyle[] usedValues
Returns a random Captcha code style. Selects from all available styles if no parameter is specified, or from the given value set if specified
BotDetect.CaptchaRandomization public method static BotDetect.ImageStyle GetRandomImageStyle
  • params BotDetect.ImageStyle[] usedValues
Returns a random Captcha image style. Selects from all available styles if no parameter is specified, or from the given value set if specified
BotDetect.CaptchaRandomization public method static BotDetect.SoundStyle GetRandomSoundStyle
  • params SoundStyle[] usedValues
Returns a random Captcha sound style. Selects from all available styles if no parameter is specified, or from the given value set if specified

BotDetect.StringHelper

A helper class used for common string operations used by BotDetect code.

BotDetect.StringHelper Class Reference
BotDetect.StringHelper public method static bool HasValue
  • string input
Checks that the suppliedstring is not null, empty, or consists of only whitespace characters
BotDetect.StringHelper public method static string[] CsvToArray
  • string csvInput
Splits the supplied comma-separated input into a string array
BotDetect.StringHelper public method static BotDetect.Set<int> GetCodePoints
  • System.Collections. Specialized.StringCollection chars
Converts the given collection of characters into Unicode code points
BotDetect.StringHelper public method static System.Collections. Specialized.StringCollection ParseCsv
  • string csvInput
Splits the supplied comma-separated input into a character collection
BotDetect.StringHelper public method static string LogFriendly
  • params object[] values
Writes the given input to a log-friendly string
BotDetect.StringHelper public method static string LogFriendly
  • params string[] values
Writes the given input to a log-friendly string
BotDetect.StringHelper public method static string LogFriendly
  • string input
Writes the given input to a log-friendly string
BotDetect.StringHelper public method static string ToString
  • System.DateTime input
Writes the given input to a log-friendly string
BotDetect.StringHelper public method static string ToString
  • object input
Writes the given input to a log-friendly string
BotDetect.StringHelper public method static System.Text.StringBuilder LogFriendlyWrite
  • System.Text.StringBuilder sb
  • params string[] values
Writes the given input to the StringBuilder instance in a log-friendly format

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.