简体   繁体   English

Asp.Net WebForms .Net Fwk 4.6.1:找不到System.Web.Helpers.AntiForgery库

[英]Asp.Net WebForms .Net Fwk 4.6.1: Can't find System.Web.Helpers.AntiForgery library

I have a Asp.Net (4.6.1) WebForms project, and I'm trying to implement the AntiForgery prevention like the Microsoft documentation. 我有一个Asp.Net(4.6.1)WebForms项目,并且我正在尝试像Microsoft文档一样实施AntiForgery防护。 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() %> 事实是,我找不到要安装的库并无法实现该库,如下所示: <%= 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 . 特别是,您需要搜索该类的参考文档:仅针对System.Web.Helpers.AntiForgery Google。

You'll find the MSDN page: https://msdn.microsoft.com/en-us/library/system.web.helpers.antiforgery(v=vs.111).aspx 您将找到MSDN页面: https : //msdn.microsoft.com/zh-cn/library/system.web.helpers.antiforgery(v=vs.111).aspx

In that, you can read the Assembly : System.Web.WebPages . 这样,您可以阅读AssemblySystem.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); 在Visual Studio中,您可以在项目或Reference元素上单击鼠标右键,然后为框架程序集(或您的项目)选择“添加引用...”; or, you "Manage Nuget Packages" from the same menu and install the appropriate packages from Nuget. 或者,您从同一菜单中“管理Nuget程序包”并从Nuget安装相应的程序包。 Speaking of Nuget, it's the package management solution for .NET and it's great, but it's for another question. 说到Nuget,它是.NET的软件包管理解决方案,虽然很棒,但是还有另一个问题。

In your case, I think you will need a Nuget package called microsoft-web-helpers. 就您而言,我认为您将需要一个名为microsoft-web-helpers的Nuget程序包。

https://www.nuget.org/packages/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. 编辑:我只是看了看文档,发现文档与WebMatrix有关。 You're talking about WebForms: I don't think the two are compatible, AFAICT. 您是在谈论WebForms:我认为两者不兼容,AFAICT。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM