ASP.Net MVC - Request Life Cycle [closed]

2019-01-24 11:40发布

问题:

I am trying to search the Video of Request Life Cycle of MVC.

I tried a lot on Google, but could not found it.

回答1:

This might be useful to you.

http://www.dotnet-tricks.com/Tutorial/mvc/TbR0041112-Asp.net-MVC-Request-Life-Cycle.html http://www.youtube.com/watch?v=aRZZFfKwVVU



回答2:

Below is the detail explanation of the same.

Step 1 Fill route: - 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.

Step 2 Fetch route:- 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.

Step 3 Request context created: - The “RouteData” object is used to create the “RequestContext” object.

Step 4 Controller instance created: - 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.

Step 5 Execute Action: - The “ControllerActionInvoker” determines which action to executed and executes the action.

Step 6 Result sent: - The action method executes and creates the type of result which can be a view result , file result , JSON result etc.

So in all there are six broad steps which get executed in MVC request life cycle.

courtesy the above image taken from this codeproject article http://www.codeproject.com/Articles/556995/MVC-interview-questions-with-answers



回答3:

Below is the MVC Life Cycle:

- App initalization
- Routing
- Instantiate and execute controller
- Lcate and invoke controller action
- Instantiate and render View


回答4:

Lifecycle of an ASP.NET MVC 5 Application - was published a week ago or so.

Here is a PDF file to download.

Hope that helps!



回答5:

In short. ASP.NET MVC uses ASP.NET Routing internally. When you see the MapRoute call, it's actually an extension method that will register a specific route to an MvcRouteHandler.

This route handler's GetHttpHandler will return a MvcHandler which is able to handle the request that matched the route.e.g. http://yourdomain.com/{controller}/{action}