Apply Authorize filter on all controllers within an area
问题 How can I force authorization on all controllers within an area? Specifically, I would like to configure an AuthorizeFilter to be applied on the 'admin' area as part of the Startup.ConfigureServices() method. 回答1: One way do to this is with the use of a custom IControllerModelConvention public class AuthorizeAreaConvention : IControllerModelConvention { private readonly string _area; private readonly string _policy; public AuthorizeAreaConvention(string area, string policy) { _area = area;