Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to access Controller/Action attributes from a Message Handler?

Is there a practical way to access the attributes decorating a controller or action from a Message Handler/ DelegatingHandler?

From the diagram on Pedro Felix's blog entry, it looks like Message Handler's are too early in the pipeline and the info won't be available until the Controller Dispatcher Message Handler runs. Correct?

About my use case:
I'm working with the Thinktecture identity model, and it would be useful to be able to look for the AllowAnonymous attribute in the AuthenticationHandler.

like image 540
EBarr Avatar asked Jul 03 '12 11:07

EBarr


1 Answers

By nature, this seems to be the wrong place to implement it. As you have noted, Message Handlers work across all requests and responses. If you depend on an attribute, this would naturally be a filter. So I suggest you follow that route.

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

like image 145
Aliostad Avatar answered Sep 17 '22 23:09

Aliostad