'AllowAnonymous' could not be found

我是研究僧i 提交于 2019-12-10 15:47:23

问题


Everything worked fine until I installed (Package Manager Console) the postal package, then uninstalled and installed an older version.

Now I get an error where it previously was not. Error:

The type or namespace name 'AllowAnonymous' could not be found (are you missing a using directive or an assembly reference?)

Who knows how to fix this?


回答1:


Probably you are missing the reference to System.Web.Http assembly in your project?

So you need to:

  • Add the reference to System.Web.Http;
  • Add using System.Web.Http; to your controller;

To add Reference you need to do next steps:

  • In Solution Explorer, right-click the project node and click Add Reference.
  • In the Add Reference dialog box, select the tab Assemblies, and enter System.Web.Http into search on the right side.
  • Select the component System.Web.Http, and then click OK.

Link:

How to: Add or Remove References By Using the Add Reference Dialog Box




回答2:


I had the same problem. After reinstalling a package, MVC 5 was removed and then MVC 3 was added! The following command fixed the problem:

PM> update-package


来源:https://stackoverflow.com/questions/24390033/allowanonymous-could-not-be-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!