Posts

Showing posts with the label MVC Routing

Life cycle of an Asp.Net MVC request

Image
When you invoke an action in an MVC application, everything happens as if you were simply calling a method in the controller class. How do we go from a http request to a method invocation with arguments? We will try here to describe everything that happens during the MVC request processing. Routing The first system to handle the request is routing. It analyzes the request depending on the context and chooses which controller and which action has to be called. In an MVC application, the goal of routing is to create a route data dictionary containing at least 2 entries: “controller” and “action” (+ “area” if needed). Those 2 entries will allow the correct controller to be instantiated and the correct action to be called during the next steps. Routing is an http module: System.Web.Routing.UrlRoutingModule handling the cached routing results and a http handler System.Web.Routing.UrlRoutingHandler handling the request itself. It relies on the route table defined...