2

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

I get the message:

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

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.

Anyone could help me?

Community
  • 1
  • 1
Rubia Gardini
  • 815
  • 5
  • 16
  • 30

1 Answers1

2

Here's a step by step guide:

  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>
    }
    
  4. 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");
    }
    
Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • Thank you @Darin Dimitrov, I just wonder why I couldn't use this namespace in my app, I tried to download this you told me and it tells me is already installed, so weird. Thank you a lot. – Rubia Gardini Nov 26 '11 at 13:37