Asp.net programming we consider all important topic for knowledge about controls,web Services, JSON, Ajax, database, and interview related Question. In this Asp.net and sql server tutorial blog we give many examples of jquery as like How Play YouTube Video in Your Asp.net Website by URL, How to Play YouTube Videos in Asp.net by using Jquery , Jquery Change div background on mouseover in asp.net , JQuery UI Datepicker (Calendar) etc.

Thursday, June 26, 2014

how to use CAPTCHA in asp.net

 How to use CAPTCHA  in asp.net

In this post we learn how to use how to use CAPTCHA  in asp.net, As we know that CAPTCHA  use for security. Security in the since that Accessing of internet by human. In this Post, I will explain how to use CAPTCHA  Control in ASP.Net Programming. CAPTCHA  verification control helps to avoid spam and generally used in Contact us or Sign Up forms, contact form and other where we want to use. 
This Post will only deal with the verifying that the data you are receiving is coming from an Real human being and not a robot or script or any type of software. A CAPTCHA technique is a way of testing input to ensure that you're dealing with a human.
Basically the user is shown an image with some characters and user has to fill the same character in a textbox provided, then the content of the image is matched with the textbox and if it matches it ensures that it’s a valid submission and the form gets submitted.


When we want to protect our web page Access by the automatic software or utility program. then we want to insured  that that is human which access my page.

Some time we see that when we access Google many times in particular time then the google also gives the CAPTCHA  verification. 

For using this CAPTCHA  verification in asp.net web programming here we give fallowing steps:


step by step todo a CAPTCHA  ,for my asp.net web Programming or implementation of How to use CAPTCHA  in ASP.Net

 


Step 1 :

Add the Reference of Mscaptcha.dll file in asp.net web application.

Step 2:

Register MsCaptcha in wep page.
<%@ Register Assembly="MSCaptcha" Namespace="MSCaptcha" TagPrefix="cc1" %>


Step 3:


Write some code in to the web config file in the System.web tag.

 <system.web>
    <httpHandlers>

      <add verb="GET" path="CaptchaImage.axd" type="MSCaptcha.CaptchaImageHandler, MSCaptcha  "/>
      <add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
   validate="false" />
    </httpHandlers>
       </system.web>

Step 4:


Write some code in to the web config file in the Handlers tag.

<handlers>
     
      <add name="MSCaptcha" verb="GET" path="CaptchaImage.axd" type="MSCaptcha.CaptchaImageHandler, MSCaptcha  "/>
      <remove name="ChartImageHandler" />
      <add name="CrystalImageHandler.aspx_GET" verb="GET" path="CrystalImageHandler.aspx"
       type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
       preCondition="integratedMode" />
     

    </handlers>

Step 4 : write code on web page where you want to add Captcha.

  <cc1:captchacontrol ID="ccJoin" runat="server" CaptchaBackgroundNoise="none" CaptchaLength="5"
                CaptchaHeight="40" CaptchaWidth="150" CaptchaLineNoise="None" CaptchaMinTimeout="5"
                CaptchaMaxTimeout="140" FontColor="Red" Width="155px" />

            <asp:TextBox ID="txtCaptcha" runat="server" placeholder="Type above text."></asp:TextBox>

Step 3:


 write on the C# page (code page ) on submit button click event.

ccJoin.ValidateCaptcha(txtCaptcha.Text);
        if (!ccJoin.UserValidated)
        {
            lblMsg.Visible = true;
            lblMsg.Text = "Invalid Text. Try Again!";
            return; //Inform user that his input was wrong ...
        }


These are five steps ,by this you can use Captcha in your application easily. I think this is use full for you ,here we also give you code .