A way to exclude action filters in ASP.NET MVC?

前端 未结 2 899
一生所求
一生所求 2020-12-23 18:41

I\'ve run into several cases in ASP.NET MVC where I wanted to apply an action filter on every action except one or two. For example, say you have an AccountController. Eve

2条回答
  •  南笙
    南笙 (楼主)
    2020-12-23 19:18

    I assume for years ago that the [AllowAnnonymous] attribute hadn't been added to ASP.NET MVC. Today I can have the [Authorize] attribute on top of my controller applying to all the Action methods and I just simply override this in Actions I require unauthorized users by adding the [AllowAnonymous] attributes to the specific actions.

提交回复
热议问题