问题
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