2

我有 reCaptcha 安装问题。我已经看过一些关于这个的帖子,即使在 StackOverflow 中,但它并没有帮助我让它工作。

我关注了这篇文章这篇文章,但在这一行:

@using Microsoft.Web.Helpers

我收到消息:

命名空间“Microsoft.Web”中不存在类型或命名空间名称“Helpers”(您是否缺少程序集引用?)

我添加了所有提到的引用,web.config 文件(根和视图文件夹)中的所有程序集,重新启动 VS2010,更新了 MVC3 包,包括 WebMatrix 包,但我无法让它工作。

我想它应该很容易安装,但我不知道我做错了什么。

任何人都可以帮助我吗?

4

1 回答 1

2

这是一个分步指南:

  1. 使用默认模板创建一个新的 ASP.NET MVC 3 项目
  2. 安装microsoft-web-helpersNuGet
  3. 在创建表单并将命名空间纳入范围的Index.cshtml视图中:HomeControllerMicrosoft.Web.Helpers

    @using Microsoft.Web.Helpers
    
    @using (Html.BeginForm())
    {
        @ReCaptcha.GetHtml(publicKey: "__ put your public key here __")
        <button type="submit">OK</button>
    }
    
  4. 并验证控制器中的验证码:

    [HttpPost]
    public ActionResult Index(MyViewModel model)
    {
        if (!ReCaptcha.Validate(privateKey: "__ put your private key here __"))
        {
            return View(model);
        }
        return RedirectToAction("success");
    }
    
于 2011-11-26T09:37:47.550 回答