Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET MVC CAPTCHA implementation

I am attempting to implement a Captcha on a partial view of a page in my application. I have the captcha being refrenced through web.config as a control. I have used the GenericHandler and Class file from this forum post: http://forums.asp.net/t/1871186.aspx/1

How can I reference the user's input if i am using a simple input tag? Should I use an HtmlHelper instead?

           <div class="captcha">
                <rhcap:Captcha ID="Captcha1" runat="server"></rhcap:Captcha>
                <input type="text" id="UserCaptchaText"><input/>
                <%= Html.TextAreaFor(m => m.UserCaptcha) %>
            </div>

            <%if(Captcha1.Text != /* How can get the users input here?*/ ) {
                  //display error

            }else{
                   //proceed
            }%>
like image 439
user1977591 Avatar asked May 13 '13 14:05

user1977591


People also ask

How do you implement Captcha?

Go to the reCAPTCHA homepage and click on the Get reCAPTCHA button at the top of the screen. On the next screen, you'll find a prompt to enter a label and domain for your site, so you can identify it among your reCAPTCHA properties. Populate both fields, click on Register, and you're done.


1 Answers

Use NuGet and install Recaptcha for .NET (supports MVC as well)

http://nuget.org/packages/RecaptchaNet/

Documentation is on the site:

http://recaptchanet.codeplex.com/

There are other captchas:

http://captchamvc.codeplex.com/

EDIT:

This project has moved to GitHub https://github.com/tanveery/recaptcha-net

like image 153
Erik Funkenbusch Avatar answered Sep 18 '22 00:09

Erik Funkenbusch