Capchas in ASP.Net Web Form

The capchas are really very good thing to prevent bots from autofilling and securing our site.We can generate the capchas by our code but we can get some ready made capchas so there is no need to generate them and wasting time especially when they are very good.
Here two types of capchas and the screen shot of those capchas are as below:

Screen shot of the capchas:-


You can see that both capchas are very good. The second one is very famous as it is provided by the google and known as recapchas.

First let us see about first capcha which is known as mscapcha.

First you need to download the dll file for ms capcha which can found from 

After downloading just put that dll in your bin file folder. If you have downloaded my example than you can directly get that from my example's bin folder.

After putting in bin folder you need to add the reference of this dll in your project and modify your web.config file by putting this line

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

Under  <httphandlers> section

After that it will look like:

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

Now just add one line on your page where you are going to use this capcha:
<%@  Register Assembly="MSCaptcha"  Namespace="MSCaptcha" TagPrefix="cc1" %>
And you are ready to use this capcha; add the capcha anywhere such as:
<cc1:CaptchaControl ID="ccJoin" runat="server" FontColor="Red" ForeColor="AliceBlue"  NoiseColor="Red" CaptchaBackgroundNoise="Extreme"  CaptchaLength="5" CaptchaHeight="40" CaptchaWidth="150" CaptchaLineNoise="None" CaptchaMinTimeout="5" CaptchaMaxTimeout="240"  />
It will give you new capcha every time when the page refresh occurs.

To validate this capcha, you simply need to check like:

protected void Button1_Click(object sender, EventArgs e)
    if (!ccJoin.UserValidated)
        Page.RegisterStartupScript("asd", "<script language='javascript'>alert('capchu khotu 6');</script>");
        Page.RegisterStartupScript("asd", "<script language='javascript'>alert('capchu sachu 6');</script>");

From your .cs page

Now for the recapcha provided by google.

First, in order to use recapcha you have to register yourself from here

After registration you will get two keys

PublicKey, PrivateKey which are very useful

You also need to download recapcha dll which can be found from here

After downloading that dll you have to add that as a reference. In the page on which you want to use it add this line:

<%@ Register TagPrefix="recaptcha" Namespace="Recaptcha" Assembly="Recaptcha" %>

After doing that you are ready to use recapcha,.
Just add this tag anywhere to use recapcha:

    runat="server" BackColor="AliceBlue" ForeColor="Red"