Apply my custom "Authorize" attribute to all routes in ASP.NET Core

24 Views Asked by At

How to add custom authorize attribute to all routes in ASP.NET Core?

I have my own custom authorize attribute and want to add it to all routes of my application. If a request comes to any route, first check my custom attribute, then resume request. I can do it by applying it manually on every controller or action, but i want do it for all controllers and actions automatically.

It's like

app.MapControllers().RequireAuthorization();

If want to use my custom attribute, how to apply it to all routes?

0

There are 0 best solutions below