The CaptchaImage validation mechanism
The CaptchaImage text is configurable by specifying TextLength (default 5) and the list of allowed chars (by default 'ABCDEFHKLMNPRTVXYZ234789');
the appearance is also configurable by specifying DistortionStyle type (Confetti, Gradient, Holes or Random)
and ReadnessLevel type (3 levels, default is Normal).
<piece:CaptchaImage ID="CaptchaImage1" runat="server" ReadnessLevel="Hard"
TextLength="7">
<Text Color="Purple" Font="Arial, 28pt, style=Bold" HorizontalAlign="Center" VerticalAlign="Center" />
</piece:CaptchaImage>
The CaptchaImage should be used together with ServerCacheDuration because the image is by default randomly warped
each time it's requested, even is the text is unchanged. This is not an issue for when the text changes because
then the server cache is automaticaly invalidated.
At some point, the text can be changed very simple
protected void Button1_Click(object sender, EventArgs e)
{
this.CaptchaImage1.ResetText();
}
The validation is also straight forward
protected void Button2_Click(object sender, EventArgs e)
{
if (this.CaptchaImage1.IsValid(this.TextBox1.Text, true))
{
// ok
}
else
{
// nok
}
}