Captcha Protection in ASP.Net

Captcha is a tool that helps protect your site from automated bots that waste precious server resources. It has been implemented in several CMS, however, there’s no straightforward guide for ASP implementation, and that’s why in this article I will give you a step by step guide on how to integrate Captcha in ASP.Net

Getting Started

1. Download Captcha:

2. Once you download it, there is going to be an example page that is going to show you how to use this interesting control. However, we are going to add this control into a different project.

3. Add the classes Letter.cs and SecurityHelper.cs  Those files are in the “App_Code” folder, from the downloaded Captcha file:

14. Open your web site project. Right click on it and in the contextual menu click on “Add“, then select “Class“:


5. Now copy the files in your project. In your project Create a new folder called “Captcha” and put the following files inside it:

3 4

6. To integrate captcha, open the file that you want to implement it, then copy the next code at the beginning of the file:

<%@ Register src="MyCaptcha.ascx" tagname="MyCaptcha" tagprefix="uc1" %>

7. After that, place the following code exactly where you need to show captcha:

<uc1:MyCaptcha ID="MyCaptcha1" runat="server" />

<br />

<asp:Label ID="lblCheckResult" runat="server" Text="?"></asp:Label>

<br />

8. Finally, change the code for your “action button” for this one:

<asp:Button ID="btnCheck" runat="server" onclick="btnCheck_Click"

Text="Check it!" />

9. And that’s it! Now you can implement it in any part of your site,  (login forms, comments, entries, etc):


This concludes Captcha Protection in ASP.Net

Looking for quality Windows Hosting? Look no further than Arvixe Web Hosting!

Happy Hosting!

Rodolfo Hernandez

Tags: , , , , , , , , , , , , , , , , , | Posted under ASP .NET 4.0 | RSS 2.0

Author Spotlight

Rodolfo Hernandez

I like photography and reading books. Currently working for Arvixe as Elgg Community Liaison. Elgg Security Expert Web Security Expert CEO of UDP SW Social Web

Leave a Reply

Your email address will not be published. Required fields are marked *