Therefore, I need to introduce several different services into the authorization attribute that I use. For simplicity, I will leave this to show the configuration manager.
public class FeatureAuthorizeAttribute : AuthorizeAttribute { public IConfigurationManager ConfigurationManager; private readonly string _feature; public FeatureAuthorizeAttribute(string feature) { _feature = feature; var test = ConfigurationManager.GetCdnPath(); } }
which will be used as follows
[FeatureAuthorize("Admin")]
I tried using constructor injection
public FeatureAuthorizeAttribute(string feature, IConfigurationManager configurationManager) { ConfigurationManager = configurationManager; _feature = feature }
However, this just causes an error when trying
[FeatureAuthorize("Admin", IConfigurationManager)]
It seems that this is not so. I assume that I need to register my own authorization attribute with the container so that it starts collecting
source share