Is there a way to remove a Global DelegatingHandler from a specific Route? #1958
Answered
by
raman-m
henrysmith
asked this question in
Q&A
-
I registered an auth global DelegatingHandler that applies to my routes. However, there are a couple of routes that I need to avoid this handler. My solution now is to set it as "no" global and add it route by route. So, my question: is there a way to remove a Global DelegatingHandler from a specific Route? If not, I think it would be a useful feature. Henry |
Beta Was this translation helpful? Give feedback.
Answered by
raman-m
Feb 8, 2024
Replies: 1 comment 1 reply
-
@henrysmith Hi Henry!
Yes, it would! |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Henry,
Because you developed custom delegating handler it will be better to exclude the routes right in the
SendAsync
method. If you've detected the route to exclude, just callbase.SendAsync
and the delegating handler will not process.The collection of the routes to exclude you can save in appsettings.json, then inject
IOptions<TSection>
object into the constructor.Why not to implement this solution?