Using ReCaptcha with MVC3 and Razor?

How exactly do you get ReCaptcha's work in MVC3 with a razor? I tried "Install-Package microsoft-web-helpers", but still could not get it to work on my razor .cshtml page, it cannot find the type ReCaptcha. And, at http://nuget.org/List/Packages/microsoft-web-helpers , someone left a comment saying: "This package currently only works with WebMatrix." Although this article shows that this can work http://www.dotnetcurry.com/ShowArticle.aspx?ID=611

+6
source share
4 answers

You may need to make the Microsoft.Web.Helpers namespace available for views. In your Web.config (in the Views folder) add:

 <namespaces> <!-- other namespaces here --> <add namespace="Microsoft.Web.Helpers"/> </namespaces> 

You can then use the following helper in your view:

 @ReCaptcha.Validate([public key]) 

If the namespaces parameter does not work, you can try adding the @using Microsoft.Web.Helpers statement on top of the view to see if this helps. If so, you need to try to find out why the namespace parameter in web.config does not work ...

+6
source

It may be too late for the party, but I could not get any of the examples to work with MVC3. Microsoft doesn't seem to be working either.

Finally, we downloaded the reCaptcha binary from google code for .net - http://code.google.com/p/recaptcha/downloads/list and created a special html razor helper.

Code is available on Github - https://github.com/clearinterface/MvcRecaptcha

Hope this helps.

+1
source

The answers above are not 100% complete, so I wrote a tutorial that covers every single step .

-2
source

Source: https://habr.com/ru/post/885920/