Is there a elegant way to require a开发者_C百科ll actions to require [Authorize] without having to use an AOP framework or similar? It seems to easy too forget to put the attribute on all controllers. I guess creating a base controller also can solve this, but again.. It's possible to forget to inherit from this one.
Putting it on the base controller is the easiest thing to do. To enforce compliance, you could write a unit test which enumerates over all the Controller types in your application and does a check to make sure that they subclass your CustomControllerBase.
精彩评论