问题描述
我有验证码的安装问题。我已经看到了有关某些职位,甚至在计算器,但它并没有帮助我得到它的工作。
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.
我也跟着这个帖子和但在这一行:
I followed this post, and this post but in this line:
@using Microsoft.Web.Helpers
我得到的消息:
类型或命名空间名称'助手'不存在命名空间'Microsoft.Web存在(是否缺少程序集引用?)
我添加了两个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:
- 使用默认模板创建一个新的ASP.NET MVC 3项目
- 安装
微软网络助手
的NuGet -
在的
Index.cshtml
视图的HomeController
创建一个表单,并把Microsoft.Web.Helpers
命名空间到范围:
- Create a new ASP.NET MVC 3 project using the default template
- Install the
microsoft-web-helpers
NuGet In the
Index.cshtml
view ofHomeController
create a form and bring theMicrosoft.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工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!