I stumbled across the MessageProcessingHandler
class in WebAPI. It's a child of DelegatingHandler
. There's almost no information out there on the class and MS documentation is particularly thin, simply saying:
The
MessageProcessingHandler
is useful if the handler doesn't require asynchronous operations, because operations on request and response messages are fast. The most common usage is to derive from this class and override theProcessRequest
andProcessResponse
methods.
So I thought I'd take the class out for a spin, see how it feels. I'm stumped on one thing... how can I end the processing pipeline and send a ResponseMessage
back?
For example: say I have a handler that checks for authentication, the check fails, and I want to return an HTTP 401/403 (I'm not saying which so I can avoid a holy war :-). It doesn't seem possible with MessageProcessingHandler
. Right?