I have a WebAPI project currently that implements the [Authorize] on all methods globally by adding the following code in my Startup.cs. This is a great
config.Filters.Add(new AuthorizeAttribute());
Can I dynamically remove this attribute from selected methods? Is there a way to do this or would I have to manually apply to the end points?
The only other solution I can think of is to have a flag on that attribute, but then it would be applied twice which would make no sense.
Thanks!
You can use [AllowAnonymous] attribute for disabling Authorization. This attribute is for classes, methods etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With