title: Message Handlers and the Http Module?
body: <blockquote>
    <p>In ASP.NET Web API, HTTP requests and responses are processed in a
    pipeline on the server.</p>
  </blockquote>
  
  <p>If I want to add some logic or global behaviour  at the very early stages of the pipeline , I should do it in the Message Handler. ( for example : authentication)</p>
  
  <p>But what about the Http module pipeline ? where it fits in this whole story ? </p>
  
  <p>Looking at this numbered stages of web api life cycle : </p>
  
  <p><a href="https://i.stack.imgur.com/jkQe8.jpg" rel="nofollow noreferrer">http://i.stack.imgur.com/jkQe8.jpg</a></p>
  
  <p><img src="https://i.stack.imgur.com/jkQe8.jpg" alt="enter image description here"></p>
  
  <p><strong>But</strong> looking at the Http module general events ( contains more but...) <img src="https://i.stack.imgur.com/ahK6P.jpg" alt="enter image description here"></p>
  
  <p><strong>Question :</strong> </p>
  
  <p>— How those 2 systems combine and where ?  I mean if there was 1 picture which contains web api and http module , how would the numbers be ? (I added numbers in the images for easy referencing)</p>
  
  <p>— I always hear that If i want to do things earlier at the pipeline I should use message handlers , but what about HttpModule's <code>BeginRequest</code> for example ?  I know that there are objects which are null at this stage but still  , later phases at the httpmodule does inflate HttpContetxt's objects - and yet , webapi's guys says : use MessageHandlers....(is it relate to the fact of selfhoster environment) ?</p>