To combine the figure lower to upper, imagine that the IHttpHandler field in the upper figure corresponds to the ASPX in the image below, so that you place the lower image in the lower left upper. So, 8 and 9 are part of the ASP.NET IIS pipeline. IIS pipeline runs modules, etc. And it ends when the handler processes the request. With the web API, this handler turns out to be the HttpControllerHandler , and here the web API pipeline begins. If you look at the HttpControllerHandler , the request and response will be ASP.NET specific left and right, it will become the HttpRequestMesssage , which is specific to the Web API.
To your second question, the earliest of which you can do in the Web API pipeline will be a message handler. HttpModule will be even earlier, but is not part of the Web API, but is a hosting. The trade-off is that if you have an HttpModule, you can only use it in IIS, whereas a message handler can work on any host, as it is specific to the web API and specific to the host. I keep referring to my MSDN article in my recent SO answers, but then it happens that the article is relevant to the questions asked. So, I have no choice but to tie it again. Here you go . I compare the various options in this article.
source share