Routing and dispatching
The routing and dispatching stage primarily involves the execution of a series of message handlers, which process the incoming request and then delegate them to the next message handler for processing. In earlier versions of ASP.NET Web API, we could only configure message handlers globally per application. All the message handlers were added to the HttpConfiguration.MessageHandlers
collection and were executed for each request. The global configuration was enabled using the Register
method in the WebApiConfig.cs
file, which gets added when creating a new ASP.NET Web API project. We talk more about the WebApiConfig
and Register
method in the Creating our first ASP.NET Web API section. The following snippet show a sample Register
method definition:
public static void Register(HttpConfiguration config) { config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter...