验证码和MVC3,问题越来越Microsoft.Web.Helpers工作 [英] ReCaptcha and MVC3, problems getting Microsoft.Web.Helpers working

查看:92
本文介绍了验证码和MVC3,问题越来越Microsoft.Web.Helpers工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有验证码的安装问题。我已经看到了有关某些职位,甚至在计算器,但它并没有帮助我得到它的工作。

I have reCaptcha installation problems. I already saw some posts about that, even in StackOverflow but it didn't help me to get it working.

我也跟着<一个href=\"http://ihatethissite.com/blog/2011/02/27/recaptcha-with-asp-net-mvc-razor-using-microsoft-web-helpers/\"相对=nofollow>这个帖子和这个帖子但在这一行:

I followed this post, and this post but in this line:

@using Microsoft.Web.Helpers

我得到的消息:

类型或命名空间名称'助手'不存在命名空间'Microsoft.Web存在(是否缺少程序集引用?)

The type or namespace name 'Helpers' does not exist in the namespace 'Microsoft.Web' (are you missing an assembly reference?)

我添加了两个Web.config文件中(根和查看文件夹),重新启动VS2010,更新了MVC3包,包括包WebMatrix的,但我不能让它工作。提到的所有参考文献,所有的组件

I added all references mentioned, all assemblies in both web.config files (root and view folder), restarted VS2010, updated the MVC3 package, included WebMatrix packages but I couldn't get it working.

我想这应该是安装简单,但我不知道我做错了。

I guess it should be simple to install, but I don't know what I'm doing wrong.

任何人都可以帮我吗?

推荐答案

下面是一个循序渐进的指南:

Here's a step by step guide:


  1. 使用默认模板创建一个新的ASP.NET MVC 3项目

  2. 安装微软网络助手的NuGet

  3. 在的 Index.cshtml 视图的HomeController 创建一个表单,并把 Microsoft.Web.Helpers 命名空间到范围:

  1. Create a new ASP.NET MVC 3 project using the default template
  2. Install the microsoft-web-helpers NuGet
  3. In the Index.cshtml view of HomeController create a form and bring the Microsoft.Web.Helpers namespace into scope:

@using Microsoft.Web.Helpers

@using (Html.BeginForm())
{
    @ReCaptcha.GetHtml(publicKey: "__ put your public key here __")
    <button type="submit">OK</button>
}


  • 和验证验证码控制器:

  • And to validate the Captcha in the controller:

    [HttpPost]
    public ActionResult Index(MyViewModel model)
    {
        if (!ReCaptcha.Validate(privateKey: "__ put your private key here __"))
        {
            return View(model);
        }
        return RedirectToAction("success");
    }
    


  • 这篇关于验证码和MVC3,问题越来越Microsoft.Web.Helpers工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆