BotDetect ASP.NET CAPTCHA Core API Reference
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 class
- BotDetect.Code class
- BotDetect.CodeCollection class
- BotDetect.DisallowedCodeSubstrings class
- BotDetect.CaptchaRandomization class
- BotDetect.StringHelper class
BotDetect.CaptchaBase
A base Captcha object, representing a generic Captcha instance capable of generating Captcha codes, images and sounds + validating user inputs. The Captcha 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 | ||
---|---|---|
CaptchaBase
|
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 | |
string CaptchaId | Captcha identifier, distinguishing multiple Captcha instances within the system. Can also be accessed through this property, after being initialized in the constructor | |
int CodeLength | Number of characters in randomly generated Captcha codes (answers to Captcha challenges). The default value is random (4-6 characters) | |
BotDetect.CodeStyle CodeStyle | Character types, used to generate random 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.). The default value is empty (Captcha code filtering is optional) | |
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.). The default value is empty (Captcha code filtering is optional) | |
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. The default value is 1200 seconds (20 minutes) | |
BotDetect.ImageStyle ImageStyle | Image style, The BotDetect drawing algorithm used to render Captcha codes in image Captcha challenges. The default value is random (an image style is chosen from all available values for each Captcha image generated) | |
System.Drawing.Size ImageSize | Size of Captcha image challenges generated. The default value is 250 x 50 pixels | |
BotDetect.ImageFormat ImageFormat | Image format in which Captcha images will be generated and sent to the client. The default value 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. The default value is true | |
BotDetect.SoundStyle SoundStyle | The BotDetect audio generation algorithm used to pronounce Captcha codes in sound Captcha challenges. The default value is random (a sound style is chosen from all available values for each Captcha sound generated) | |
BotDetect.SoundFormat SoundFormat | Audio format Captcha sounds will be generated and sent to the client. The default value is WavPcm16bit8kHzMono | |
BotDetect.SoundRegenerationMode SoundRegenerationMode | How will multiple consecutive requests for audio Captcha with the same Captcha code ('sound regeneration') be handled by BotDetect - a tradeoff of security, usability, and storage requirements. The default value is |
|
string Locale | Captcha locale string, determining the exact character set used for random Captcha code generation and the pronunciation language used for sound Captcha generation. The default value is en-US | |
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 | |
readonly string InstanceId | Globally unique identifier of the current CaptchaBase object instance | |
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 | |
string GetCode
|
Generates a random Captcha code for the given purpose, using settings stored in instance data belonging to the specified instanceId | |
System.IO.MemoryStream GetImage
|
Generates a Captcha image, using settings stored in instance data belonging to the specified instanceId | |
System.IO.MemoryStream GetSound
|
Generates a Captcha sound, using settings stored in instance data belonging to the specified instanceId | |
bool Validate
|
Compares the user input to the Captcha code stored for the given instanceId, using validation rules specified for the current ValidationAttemptOrigin | |
static void RegisterGenerating CaptchaCodeHandler
|
Propagate GeneratingCaptchaCode event handlers registered in delegating classes to the global event delegate | |
static void RegisterGenerated CaptchaCodeHandler
|
Propagate GeneratedCaptchaCode event handlers registered in delegating classes to the global event delegate | |
static void RegisterGenerating CaptchaImageHandler
|
Propagate GeneratingCaptchaImage event handlers registered in delegating classes to the global event delegate | |
static void RegisterGenerated CaptchaImageHandler
|
Propagate GeneratedCaptchaImage event handlers registered in delegating classes to the global event delegate | |
static void RegisterGenerating CaptchaSoundHandler
|
Propagate GeneratingCaptchaSound event handlers registered in delegating classes to the global event delegate | |
static void RegisterGenerated CaptchaSoundHandler
|
Propagate GeneratedCaptchaSound event handlers registered in delegating classes to the global event delegate | |
static void RegisterValidating UserInputHandler
|
Propagate ValidatingUserInput event handlers registered in delegating classes to the global event delegate | |
static void RegisterValidated UserInputHandler
|
Propagate ValidatedUserInput event handlers registered in delegating classes to the global event delegate |
BotDetect.Code
Represents a single randomly generated Captcha code.
BotDetect.Code Class Reference | ||
---|---|---|
Code
|
The constructor takes the freshly generated random Captcha code that will be contained in the object | |
bool IsUsedForSoundGeneration | Has the Captcha code been used to generate a Captcha sound | |
bool IsUsedForImageGeneration | Has the Captcha code been used to generate a Captcha image | |
readonly string CaptchaCode | The random Captcha code contained in the object | |
readonly System.DateTime GenerationTime | When was the random Captcha code generated | |
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 | ||
---|---|---|
CodeCollection | The default CodeCollection constructor takes no arguments | |
public IEnumerator <BotDetect.Code> GetEnumerator | Allows enumerating the contained Code instances | |
string GetCode
|
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 | |
void SaveCode
|
Stores a Code object in the collection | |
bool Validate
|
Compares the user input to stored values matching the criteria | |
readonly int Count | How many Code instances are contained in the collection |
BotDetect.DisallowedCodeSubstrings
Represents a collection of disallowed code substrings that will be excluded from all randomly generated Captcha codes.
BotDetect.DisallowedCodeSubstrings Class Reference | ||
---|---|---|
DisallowedCodeSubstrings
|
The default DisallowedCodeSubstrings constructor takes a list of disallowed substrings as simple strings | |
BotDetect.DisallowedCodeSubstrings FromList
|
||
BotDetect.DisallowedCodeSubstrings FromCsv
|
||
BotDetect.Set<int> GetDisallowedCharacters | Returns the full set of individual disallowed Unicode code points (which can also be specified this way) | |
BotDetect.Set<int> GetDisallowedCharacters
|
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 substring |
BotDetect.CaptchaRandomization
A helper class used for easy randomization of Captcha parameters.
BotDetect.CaptchaRandomization Class Reference | ||
---|---|---|
static int GetRandomCodeLength | Returns a random Captcha code length, using default code length bounds | |
static int GetRandomCodeLength
|
Returns a random Captcha code length, using the default minimal value and the specified maximal value | |
static int GetRandomCodeLength
|
Returns a random Captcha code length, using the specified minimal and maximal values | |
static BotDetect.CodeStyle GetRandomCodeStyle
|
Returns a random Captcha code style. Selects from all available styles if no parameter is specified, or from the given value set if specified | |
static BotDetect.ImageStyle GetRandomImageStyle
|
Returns a random Captcha image style. Selects from all available styles if no parameter is specified, or from the given value set if specified | |
static BotDetect.SoundStyle GetRandomSoundStyle
|
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 | ||
---|---|---|
static bool HasValue
|
Checks that the suppliedstring is not null, empty, or consists of only whitespace characters | |
static string[] CsvToArray
|
Splits the supplied comma-separated input into a string array | |
static BotDetect.Set<int> GetCodePoints
|
Converts the given collection of characters into Unicode code points | |
static System.Collections. Specialized.StringCollection ParseCsv
|
Splits the supplied comma-separated input into a character collection | |
static string LogFriendly
|
Writes the given input to a log-friendly string | |
static string LogFriendly
|
Writes the given input to a log-friendly string | |
static string LogFriendly
|
Writes the given input to a log-friendly string | |
static string ToString
|
Writes the given input to a log-friendly string | |
static string ToString
|
Writes the given input to a log-friendly string | |
static System.Text.StringBuilder LogFriendlyWrite
|
Writes the given input to the StringBuilder instance in a log-friendly format |
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