On the server side, the Web API pipeline uses some built-in message handlers:
- HttpServer gets the request from the host.
- HttpRoutingDispatcher dispatches the request based on the route.
- HttpControllerDispatcher sends the request to a Web API controller.
You can add custom handlers to the pipeline. Message handlers are good for cross-cutting concerns that operate at the level of HTTP messages (rather than controller actions). For example, a message handler might:
- Read or modify request headers.
- Add a response header to responses.
- Validate requests before they reach the controller.
This diagram shows two custom handlers inserted into the pipeline: