How to Create Mathematical Captcha in Asp.net


Description:- HTML forms which use a math-based CAPTCHA to prevent automated form submissions.This type of CAPTCHA can be easily bypassed. Here, for the purposes of education, is how to do it using the Calcatraz Calculator API.The field requires the user to complete a math-based challenge. Only if the user answers the challenge correctly.

Step 1: Design your Webpage like below.

<div>
   <uc:ASPNET_Captcha ID="ucCaptcha" runat="server" Align="Middle" Color="#FF0000" />
   <asp:TextBox ID="txtCaptcha" runat="server"></asp:TextBox>
   <br />
   <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="Submit" />
   <br />
   <asp:Label ID="lblMessage" runat="server" Text=""></asp:Label>
</div>

Step 2: Now register you Dll File Download from below link.

Step 3: Now Generate Submit Button Event and On Submit Button Event Code for Validation Captcha Which is Validate and Generate Mathematical Captcha in Webpage.

protected void Submit(object sender, EventArgs e)
{
  bool isValid = ucCaptcha.Validate(txtCaptcha.Text.Trim());
  if (isValid)
  {
     lblMessage.Text = "Valid!";
     lblMessage.ForeColor = Color.Green;
  }
  else
  {
     lblMessage.Text = "Invalid!";
     lblMessage.ForeColor = Color.Red;
  }
}

Step 4: Don’t forgot to check Image Handler File is Generate in Web.config File.

<httpHandlers>
   <add verb="GET" path="Image.ashx" type="ASPNET_Captcha.Image, ASPNET_Captcha" />
</httpHandlers>

Step 5: Now run your Webpage There you can see your Mathematical Captcha.

Step 6: For Validation you can Fill Captcha and Click Submit Button to Validate and Regenerate Captcha image.
  

Related Posts

Previous
Next Post »

1 comments:

comments
Anonymous
August 20, 2017 at 8:50:00 AM GMT+5:30 delete

cheap auto insurance
cheap car insurance quotes
car insurance quotes
auto insurance quotes

Reply
avatar

Thanks for comments.....