7

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!

1 Answer 1

7

You can use [AllowAnonymous] attribute for disabling Authorization. This attribute is for classes, methods etc.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.