ASP.NET Coreコントローラのカスタム属性を取得

1746 ワード

/// <summary>
    ///     Microsoft.AspNetCore.Mvc.Internal.AuthorizationApplicationModelProvider
    /// </summary>
    public class TestApplicationModelProvider : IApplicationModelProvider
    {
        public void OnProvidersExecuting(ApplicationModelProviderContext context)
        {
            //             
            var ad = context.Result.Controllers.First().Attributes.OfType<IAuthorizeData>();
        }

        public void OnProvidersExecuted(ApplicationModelProviderContext context)
        {
        }

        public int Order { get; } = -1000 + 10;
    }

登録:services.AddTransient();