排除授权在ASP.net MVC的一些行动 [英] Exclude some actions from Authorize in ASP.net MVC
问题描述
有是,这意味着它包含了所有我的行为在我的位指示之上的授权属性。
我想排除这个属性的一些行动(这些行动提供匿名用户)。这可能吗?
[授权]
公共类的TestController:控制器
{
公众的ActionResult指数()
{
...
}
... //通过匿名
公众的ActionResult测试()
{
...
}
}
您可以在创建一个使用AllowAnonymous属性,并把这个属性上的操作的这篇博客文章介绍的方法,你希望排除:
<一个href=\"http://blogs.msdn.com/b/rickandy/archive/2011/05/02/securing-your-asp-net-mvc-3-application.aspx\">http://blogs.msdn.com/b/rickandy/archive/2011/05/02/securing-your-asp-net-mvc-3-application.aspx
这将是vNext顺便框架。
There is an authorize attribute on top of my contoller that means it contains all of my actions. I want to exclude some actions from this attribute (these actions be available by anonymous users). Is it possible?
[Authorize]
public class TestController : Controller
{
public ActionResult Index()
{
...
}
...
//available by anonymous
public ActionResult Test()
{
...
}
}
You can take the approach outlined in this blog post of creating an AllowAnonymous attribute and placing this attribute on actions you wish to exclude:
http://blogs.msdn.com/b/rickandy/archive/2011/05/02/securing-your-asp-net-mvc-3-application.aspx
This will be in vNext of the framework by the way.
这篇关于排除授权在ASP.net MVC的一些行动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!