実際ではないかもしれませんが、カスタム属性を書きました:
public class SelectableAuthorizeAttribute : AuthorizeAttribute
{
public SelectableAuthorizeAttribute(params Type[] typesToExclude)
{
_typesToExlude = typesToExclude;
}
private readonly Type[] _typesToExlude;
public override void OnAuthorization(AuthorizationContext filterContext)
{
bool skipAuthorization = _typesToExlude.Any(type => filterContext.ActionDescriptor.ControllerDescriptor.ControllerType == type);
if (!skipAuthorization)
{
base.OnAuthorization(filterContext);
}
}
}
そして、それを私のグローバルfiletrsに登録しました:
filters.Add(new SelectableAuthorizeAttribute(typeof(MyController)));
それが誰かに役立つことを願っています