How to Use and Implement Captcha Image


Here I explained How to Use and Implement Captcha Image in C#.Net coding with Captcha.dll.Captcha image used to protect web forms against spammers.Nowadays We can see this image lot of websites and Register form or signup form end of the submit the form. The Captcha Image generate alphanumeric charecters or numbers randomly.. Basically Captcha image used to protect web forms against spammers.

How to Use and Implement Captcha Image in C#.Net with captcha.dll


Captcha image used to protect web forms against spammers.

Captcha Stands:


Completely
Automated
Public
Turing test to tell
Computers and
Humans
Apart

ie:Completely Automated Public Turing test to tell Computers and Humans Apart

Relationship between Captcha & spam


  • The internet robots is called Bots

  • which are programs made with the purpose of scouring the web for forms and e-mail addresses, are a bit different to human eyeballs.

  • In very malicious scenarios the bots will send thousands of spams through your web site form.


  • Aspx Coding Sample:





    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

    <%@ Register Assembly="MSCaptcha" Namespace="MSCaptcha" TagPrefix="cc1" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <title>Captcha Image </title>
    </head>
    <body>
    <form id="form1" runat="server">
    <div>
    <cc1:CaptchaControl ID="CaptchaControl1" runat="server" Height="107px" />

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

    <br />

    <asp:Button ID="Captcha" runat="server" Text="Check" onclick="Captcha_Click" />

    <br />
    <br />

    <asp:Label ID="LblCaptcha" runat="server">
    </asp:Label>
    </div>
    </form>
    </body>
    </html>



    File Name:Defult.aspx.cs



    using System;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;

    public partial class _Default : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Captcha_Click(object sender, EventArgs e)
    {
    CaptchaControl1.ValidateCaptcha(TxtCaptcha.Text);

    if (!CaptchaControl1.UserValidated)
    {
    LblCaptcha.Text = "You Entered Text Doesn't Match";

    return;
    }
    else
    {
    LblCaptcha.Text = "Successfully Entered";
    }

    }
    }



    In WebConfig File :




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


    I have attached Complete C# coding with output image


    Attachments

  • Download "Captcha.dll file" (42992-211250-MSCaptcha.dll)
  • Captcha Image Programming in C# (42992-211237-Capcha-Image-generation.rar)
  • Comments

    Guest Author: Ehsan10 Jan 2013

    Hi
    I'm using the profile system Membership In web.config
    After Upload The Web Site This error happens :
    Protected ReadOnly Property Profile() As ProfileCommon
    Get
    Return CType(Me.Context.Profile,ProfileCommon)
    Please Help Me
    Thanks



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: