views:

235

answers:

2

Hi all,

I am trying to learn MVC in detail, and I am wondering whats the exact functional flow internally, in the sense of which functions(important functions) are called and what they does when the application starts and which function are called apart from the controller actions that we write in our application as we proceed.

Help in this regard will be much appreciated. Please do suggest some good resources as well if you found any in this regard.

Thanks!

+5  A: 

Here are the detailed steps:

  1. Request comes into ASP.NET
  2. ASP.NET Routing finds the route match by calling RouteCollection.GetRouteData
  3. This in turn calls RouteBase.GetRouteData on each route until it finds a match
  4. The IRouteHandler for the matching route has its GetHttpHandler method called
  5. The MvcHandler runs (ProcessRequest is called)
  6. The MVC controller factory locates and creates the controller in CreateController
  7. The ControllerActionInvoker determines which action to run in InvokeAction
  8. The AuthorizationFilter stage executes (this includes the authorization method on the controller itself)
  9. The ActionExecuting stage executes
  10. The requested action method is executed
  11. The ActionExecuted stage executes
  12. If there is a result object then the ResultExecuting stage executes
  13. If the result wasn't cancelled then the ActionResult's ExecuteResult method is executed
  14. The ResultExecuted stage executes
  15. If an error occured then the Exception stage executes

I would also like to refer you to the MVC Snake Diagram that I use in many presentations on ASP.NET MVC. Here's the full image: alt text

The blog post I linked to describes some of the concepts used in ASP.NET MVC regarding how data flows through the application.

Eilon
I know this snake diagram, sadly this doesn't give me much info on what functions are called. Thanks
Mahesh Velaga
This seems better: http://www.codethinked.com/post/2008/09/27/ASPNET-MVC-Request-Flow.aspx
LukLed
I updated the text to include some more details.
Eilon
Thanks for the updates Eilon :)
Mahesh Velaga
@LukLed: Thanks for the link :)
Mahesh Velaga
+4  A: 

Check out Redgates's free "The ASP.NET MVC Request Handling Pipeline" poster for execution flow

and Steven Sanderson's MCV book for details.

Gökhan Ercan
@Gökhan Ercan: Thanks for the poster link :)
Mahesh Velaga