MVC的AllowAnonymousAttribute没有显示出来

Ben*_*esh 2 c# reference http-authentication asp.net-mvc-3

AuthorizeAttribute显示得很好,但就我而言,我无法弄清楚AllowAnonymousAttribute类的位置.

每当我将它添加到代码中时,我都会遇到编译错误.

[Authorize] //works fine
public ActionResult DoSomething(){ 
  ...
}

[AllowAnonymous] //COMPILER ERROR type not found. Red squigglies. Bad.
public ActionResult Foo() {
  ...
}
Run Code Online (Sandbox Code Playgroud)

我在一个MVC3项目中.

mer*_*rrr 5

ASP.NET MVC 3,或更确切地说,System.Web.Mvc 3.0.0.0版程序集不包含AllowAnonymousAttribute.

它是在ASP.NET MVC 4中添加的:http://msdn.microsoft.com/en-us/library/system.web.mvc.allowanonymousattribute_methods%28v=vs.108%29.aspx

System.Web.Http程序集中也有一个AllowAnonymousAttribute,但我无法使用我的ASP.NET MVC 3项目:http://msdn.microsoft.com/en-us/library/system.web.http .allowanonymousattribute%28V = vs.108%29.aspx