I have a Asp.Net (4.6.1) WebForms project, and I'm trying to implement the AntiForgery prevention like the Microsoft documentation. The thing is that I'm not able to find the library to install and allow me to implement that, like this: <%= System.Web.Helpers.AntiForgery.GetHtml() %>
It is showing me an error saying that the "Helpers doesn't belong to this namespace"
Could you guys help me please?
You need to learn how to get the necessary information from the documentation. In particular, you need to search the reference docs of the class: just Google for System.Web.Helpers.AntiForgery
.
You'll find the MSDN page: https://msdn.microsoft.com/en-us/library/system.web.helpers.antiforgery(v=vs.111).aspx
In that, you can read the Assembly: System.Web.WebPages
.
So, basically you need to add a reference to that assembly, in order to have your project access the corresponding class.
In Visual Studio, you accomplish that right clicking on the project or on the Reference element and selecting "Add Reference..." for framework assemblies (or for your projects); or, you "Manage Nuget Packages" from the same menu and install the appropriate packages from Nuget. Speaking of Nuget, it's the package management solution for .NET and it's great, but it's for another question.
In your case, I think you will need a Nuget package called microsoft-web-helpers.
https://www.nuget.org/packages/microsoft-web-helpers
Edit: I just looked up the docs and noticed that the documentation relates to WebMatrix. You're talking about WebForms: I don't think the two are compatible, AFAICT.