Is it possible to access Controller / Action attributes from a message handler?

Is there a practical way to access attributes decorating a controller or action from a message handler / DelegatingHandler?

From the diagram in Pedro Felix's blog post , it looks like the message handler is too early for the pipeline and the information will not be available until the dispatcher manager handler is processed. Right?

About my use case:
I am working with a Thinktecture authentication model, and it would be useful to be able to look up the AllowAnonymous attribute in the AuthenticationHandler .

+6
source share
1 answer

By its nature, this is apparently the wrong place to implement it. As you noted, message handlers work in all requests and responses. If you are dependent on an attribute, this will naturally be a filter. Therefore, I suggest you follow this route.

In fact, in the handler, you cannot assume that you are going to ApiController or to an action. Handlers can be used equally on clients.

+2
source

Source: https://habr.com/ru/post/919577/


All Articles