Initiates an asynchronous call, and the returned result, will be a single image of alphanumeric characters. Image’s characters are presented in various font sizes and or (+/-) rotated in some degree.
This project offers the complete Visual Studio 2012 solution within a compressed zip file. Download the complete solution from CodePlex.Shown below is the Captcha type which generates randomly selected characters and draws an image displaying those specific random characters.
Two files are involved rendering the Captcha image:- CaptchaControl.cs and CaptchaHandler.ashx
- CaptchaControl.cs is a generic control rendering out an image and an Image Button. The rendered image’s ImageUrl property is dynamically set, and calls CaptchaHandler.ashx with an attached query string. The query string has a particular name/value pair specifying the particular Captcha characters.
CaptchaHandler.ashx returns a HTTPResponse bitmap and is displayed on the client side webpage.
CaptchaControl Class
Namespace: Captcha.ControlAssembly: CaptchaControl.dll
Syntax
public CaptchaControl : WebControl
Constructors
CaptchaControl(): base(HtmlTextWriterTag.Fieldset) | Initializes a new instance of the CaptchaControl class |
Properties
string RefreshButtonPath | Absolute path to the Image Button’s image |
string CaptchaHandlerUrl | Absolute path to the Captcha Handler |
int Minimum | Minimum number of characters to be selected |
int Maximum | Maximum number of characters to be selected |
int Overlap | Amount of overlap between character placement. |
int ImageWidth | Captcha image’s width |
int ImageHeight | Captcha image’s height |
string CharacterSet | The character domain to select from. Default character set: ABDEGHMNQRTabdeghmnqr3456789#@&$% |
CaptchaCharacters Class
Namespace: Captcha.CharactersAssembly: CaptchaControl.dll
Syntax
public CaptchaCharacters
Constructors
CaptchaCharacters() | Initializes a new instance of the CaptchaCharacters class |
Properties
string characterSet | Get/Set, Sets characters domain, which characters should be included |
string characters | From the characterSet property, Gets/Sets randomly selected characters |
Methods
|
EncodeCaptcha Class
Namespace: Captcha.CharactersAssembly: CaptchaControl.dll
Syntax
public EncodeCaptcha : CaptchaCharacters
Constructors
EncodeCaptcha() | Initializes a new instance of the EncodeCaptcha class |
EncodeCaptcha(string key) | Initializes a new instance of the EncodeCaptcha class with specified encoded key string value. |
Properties
encodedKey | Sets the encoded character string. |
Methods
SaltKey() | Encodes the randomly selected characters set in the characters property. |
DrawCaptcha Class
Namespace: Captcha.CharactersAssembly: CaptchaControl.dll
Syntax
public DrawCaptcha : EncodeCaptcha
Constructors
DrawCaptcha(int, int) | Initializes a new instance of the DrawCaptcha class with specified integer width and integer height parameters. |
Properties
int[] fontSizes | Gets/Sets an array of integers specifying characters font size. |
string[] families | Gets/Sets an array of string specifying characters font family. |
string[] colors | Gets/Sets an array of string specifying characters font color. |
string backgroundColor | Gets/Sets images global background color |
int overlap | Gets/Sets amount of overlap between character placement. |
int Width | Get/Sets global Captcha image width |
int Height | Get/Sets global Captcha image height |
Methods
Bitmap DrawCaptchaString() | Draws randomly selected characters returning one bitmap with characters drawn. |
No comments:
Post a Comment