How to Use Captcha in asp.net mvc

Viewed 30651

can any one tell me how to use captcha in asp.net mvc? is there any need to download any control for it?

2 Answers

If you don't fancy writing your own Captcha (who does!) you can use a Captcha library, such as this:

http://www.coderjournal.com/2008/03/aspnet-mvc-captcha/

With a Captcha library, you add the dll to your project and use the Captcha API to display and validate the Captcha image and input.

Display a Captcha:

<label for="captcha">Enter <%= Html.CaptchaImage(50, 180) %> Below</label><br />
<%= Html.TextBox("captcha") %>

And then make sure you add the Captcha attribute to your method:

[CaptchaValidation("captcha")]

Recaptcha is just one option when it comes to Captcha's (in fact, it's the option selected by Stack Overflow!)

Related