Thursday, January 6, 2011

Including Captcha in Asp.net Application

Step1: Download MSCaptcha.dll from the Internet. Include it in your bin folder.


Step2: In Web.config file paste these line.


<httpHandlers>
<add verb="GET" path="CaptchaImage.axd" type="MSCaptcha.CaptchaImageHandler, MSCaptcha"/>
</httpHandlers>


Step3:  Place this in aspx page where you want to include Captcha.


<cc1:CaptchaControl ID="ccJoin" runat="server" CaptchaBackgroundNoise="none" CaptchaLength="5" CaptchaHeight="40" CaptchaWidth="150" CaptchaLineNoise="None" CaptchaMinTimeout="5" CaptchaMaxTimeout="240" />

Step4:  Put a textbox somewhere in your page where your user must enter what he sees in your captcha.

 <asp:TextBox ID="txtCap1" runat="server" ></asp:TextBox>

Step5:  Put this in your .cs file to validate user input.


ccJoin.ValidateCaptcha(txtCap1.Text);
if (!ccJoin.UserValidated)
{
//Inform user that his input was wrong ...

return;

}

divyashree.k

1 comment:

  1. It's working and is catchy for beginners .. thank you for the post

    ReplyDelete