我一直在遵循 google recaptcha 说明,现在我想添加服务器端验证:
https://developers.google.com/recaptcha/docs/verify
但是当我查看该页面时,我得到了一些方法的描述,但没有说明我究竟在我的 View 中写入了什么。我到底应该在我的 View 上写什么来调用谷歌的验证?
最佳答案
确保在 Controller 中引用 Recaptcha,然后在帖子上进行验证
@using Recaptcha; // goes in your controller
这是一个如何验证服务器端的例子
[HttpPost]
[RecaptchaControlMvc.CaptchaValidator]
public ActionResult ForgotPassword(CheckUsernameViewModel model, bool captchaValid, string captchaErrorMessage) {
if(ModelState.IsValid) {
if(captchaValid) {
// do stuff
}
ModelState.AddModelError("", captchaErrorMessage);
}
return View(model);
}
有关所有信息,请在此处查看我发布的答案以正确实现演练。
How to implement Google reCaptcha in an MVC3 application?
https://stackoverflow.com/questions/10939329/
相关文章:
ruby-on-rails - 尝试使用 Google Calendar API 时出现 "Miss
ruby-on-rails-3 - 在 Ruby on Rails 中,有没有一种方法可以使用 RS
reporting-services - 忽略 SSRS 设备信息配置更改
ruby-on-rails-3 - 环境与 WickedPDF 和 Heroku 冲突
azure - 防止交叉链接到 Azure Blob 存储上的图像
amazon-web-services - 将本地文件放入 Amazon EBS 卷的最快方法是什么
image - Python 从图像中去除所有 GPS 元数据