Pregunta

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.

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top