我有一个用AuthorizeAttribute装饰的控制器。控制器包含几个操作,除了需要由CustomAuthorizeAttribute提供一些自定义认证的操作之外,所有操作都需要认证。
我的问题是一旦我添加了[授权]在控制器级别可以覆盖它(或删除它与[CustomAuthorize]只是一个动作?或者,我必须从控制器级别删除[授权],并将它单独添加到每个其他操作?
我纯粹为了方便,因为我是懒惰,不想装饰每一个动作与AuthorizeAttribute。
[Authorize] public class MyController : Controller { //requires authentication public ViewResult Admin() { return View(); } //... a lot more actions requiring authentication //requires custom authentication [CustomAuthorize] //never invoked as already Failed at controller level public ViewResult Home() { return View(); } }
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。