MVC的AllowAnonymousAttribute没有显示出来 [英] MVC's AllowAnonymousAttribute not showing up

查看:201
本文介绍了MVC的AllowAnonymousAttribute没有显示出来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

该AuthorizeAttribute显示出来就好了,但对我的生活我无法揣摩出AllowAnonymousAttribute类。

The AuthorizeAttribute shows up just fine, but for the life of me I can't figure out where the AllowAnonymousAttribute class is.

每当我把它添加到code,我得到的编译器错误。

Whenever I add it to code, I get compiler errors.

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

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

我在MVC3项目。

I'm in an MVC3 project.

推荐答案

ASP.NET MVC 3,以上precisely的System.Web.Mvc版本3.0.0.0集不包含AllowAnonymousAttribute。

ASP.NET MVC 3, or more precisely the System.Web.Mvc version 3.0.0.0 assembly does not contain AllowAnonymousAttribute.

这是在ASP.NET MVC 4中添加:<一href=\"http://msdn.microsoft.com/en-us/library/system.web.mvc.allowanonymousattribute_methods%28v=vs.108%29.aspx\">http://msdn.microsoft.com/en-us/library/system.web.mvc.allowanonymousattribute_methods%28v=vs.108%29.aspx

It was added in ASP.NET MVC 4: http://msdn.microsoft.com/en-us/library/system.web.mvc.allowanonymousattribute_methods%28v=vs.108%29.aspx

有是一个Allo​​wAnonymousAttribute在System.Web.Http组装为好,但我无法得到它与我的ASP.NET MVC 3项目的工作:<一href=\"http://msdn.microsoft.com/en-us/library/system.web.http.allowanonymousattribute%28v=vs.108%29.aspx\">http://msdn.microsoft.com/en-us/library/system.web.http.allowanonymousattribute%28v=vs.108%29.aspx

There's an AllowAnonymousAttribute in System.Web.Http assembly as well, but I could not get it working with my ASP.NET MVC 3 project: http://msdn.microsoft.com/en-us/library/system.web.http.allowanonymousattribute%28v=vs.108%29.aspx

这篇关于MVC的AllowAnonymousAttribute没有显示出来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆