如何在 asp.net mvc 中使用验证码
谁能告诉我如何在 ASP.NET MVC 中使用验证码? 是否需要下载任何控件?
can any one tell me how to use captcha in asp.net mvc?
is there any need to download any control for it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
希望现在投入我的两分钱还为时不晚...
介绍 MvcReCaptcha
在尝试在我的第一个 ASP.NET MVC 站点上实现 CAPTCHA 验证时,我遇到了完全相同的问题。在发现许多库之后,我发现似乎(并且仍然看起来)是最直接、最高效的库:MvcReCaptcha。从那时起,我就在我的所有 ASP.NET MVC 站点中使用了这个库。
实施MvcReCaptcha后,它会在您的视图上安全地生成验证码,并提供一个布尔值来指示操作验证是否成功。
使用说明
以下是从项目中下载并引用 MvcReCaptcha DLL 后如何实现它(从 MvcReCaptcha 主页复制的说明):
祝你好运!
Hoping it's not too late to put my two cents in...
Introducing MvcReCaptcha
I faced this exact same issue when trying to implement CAPTCHA validation on my first ASP.NET MVC site. After discovering many libraries, I found what seemed (and still seems) to be the most straightforward and efficient library: MvcReCaptcha. Since then, I have used this library for all of my ASP.NET MVC sites.
After you implement MvcReCaptcha, it securely generates a CAPTCHA on your view and provides a boolean value of whether the validation was successful to the action.
Instructions for Use
Here's how to implement it after downloading and referencing the MvcReCaptcha DLL from your project (instructions copied from MvcReCaptcha home page):
Good luck!
如果您不喜欢编写自己的验证码(谁喜欢!),您可以使用验证码库,例如:
http://www.coderjournal.com/2008/03/aspnet-mvc-captcha/
使用 Captcha 库,您可以将 dll 添加到项目中并使用 Captcha API显示并验证验证码图像和输入。
显示验证码:
然后确保将验证码属性添加到您的方法中:
Recaptcha 只是验证码的一个选项(事实上,它是 Stack Overflow 选择的选项!)
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:
And then make sure you add the Captcha attribute to your method:
Recaptcha is just one option when it comes to Captcha's (in fact, it's the option selected by Stack Overflow!)