我试图在我的应用程序页面的部分 View 上实现验证码。我有通过 web.config refrenced 验证码作为控件。我使用了这个论坛帖子中的 GenericHandler 和 Class 文件:http://forums.asp.net/t/1871186.aspx/1
如果我使用简单的输入标签,如何引用用户的输入?我应该改用 HtmlHelper 吗?
<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
}%>
最佳答案
使用 NuGet 并为 .NET 安装 Recaptcha(也支持 MVC)
http://nuget.org/packages/RecaptchaNet/
文档在网站上:
http://recaptchanet.codeplex.com/
还有其他验证码:
http://captchamvc.codeplex.com/
编辑 :
此项目已移至 GitHub
https://github.com/tanveery/recaptcha-net
关于ASP.NET MVC CAPTCHA 实现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16524365/