Unity Inject dependencies into MVC filter class with parameters
As per the post Passive Attributes, the DI-friendly solution is to separate the AuthorizeAttribute into 2 parts: An attribute that contains no behavior to flag your controllers and action methods with. A DI-friendly class that implements IAuthorizationFilter and contains the desired behavior. For our purposes, we just inherit AuthorizeAttribute to take advantage of some of … Read more