ASP.NET Web API Message Handlers
asp.net-web-api, dotnet-httpclient
Solution
The order in which you register the handlers determines when they are called but as Aliostad points out they work in a Russian doll model so the first one in is also called as the last one out and so forth.
The registered handlesr are invoked in a bottom-up fashion in the incoming path and top-down in the outgoing. That is, the last entry is called first for an incoming request message but invoked last for an outgoing response message.
Problem
Is it possible to control the execution order of custom message handlers? As an example, I might want a logging handler to execute first, so I always log a request. Apart from adding the logging handler last, I'm failing to see how to achieve this. ``` config.MessageHandlers.Add(new CustomHandlerOne()); config.MessageHandlers.Add(new CustomHandlerTwo()); config.MessageHandlers.Add(new LoggingHandler()); ```