Step by Step Application Life Cycle in ASP.NET MVC
Dec 18, 2020 06:50 0 Comments ASP.net MVC PARTH

      Application Life Cycle in ASP.NET MVC

 

Asp.net Routing is the first step in MVC request cycle. Basically, it is a pattern matching system that matches the request’s URL against the registered URL patterns in the Route Table. When a matching pattern found in the Route Table, the Routing engine forwards the request to the corresponding IRouteHandler for that request. The default one calls the MvcHandler. The routing engine returns a 404 HTTP status code against that request if the patterns is not found in the Route Table.

MVC requests are mapped to route tables which in turn specify which controller and action to be invoked. So, if the request is the first request the first thing is to fill the route table with routes collection. This filling of route table happens in the global.asax file.

Depending on the URL sent "UrlRoutingModule" searches the route table to create "RouteData" object which has the details of which controller and action to invoke.

The "RouteData" object is used to create the "RequestContext" object.

This request object is sent to "MvcHandler" instance to create the controller class instance. Once the controller class object is created it calls the "Execute" method of the controller class.

The Execute() method gets the Action from the RouteData based on the URL. The Controller Class then call the ContollerActionInvoker that builds a list of parameters from the request.

These parameters, extracted from the request parameters, will act as method parameters. The parameters will be passed to whatever controller method gets executed.

Finally It will call the InvokeAction method to execute the Action.

Action method may return a text string, a binary file or a Json formatted data. The most important Action Result is the ViewResult, which renders and returns an HTML page to the browser by using the current view engine.

ASP.NET MVC - Life Cycle - Tutorialspoint

Prev Next
About the Author
Topic Replies (0)
Leave a Reply
Guest User

You might also like

Not sure what course is right for you?

Choose the right course for you.
Get the help of our experts and find a course that best suits your needs.


Let`s Connect