Anda di halaman 1dari 1

ASP.

NET MVC Pipeline


the lifecycle of a request in ASP.NET MVC
by Simone Chiaretta
Incoming request

Controller Creation
You are not going to enter the MVC pipeline, you are on your own now MvcHandler

Custom

3
MvcRouteHandler DependencyResolver finds and create instance of Controller

What type of IRouteHandler ?

Controller Factory

Routing

2
Evaluate requested URL against route Definition (including iRouteConstraint)
is the route valid? Yes IRouteHandler Controller No ControllerActionInvoker ActionInvoker Custom You are getting out of the default MVC workflow. You have to handle action and result execution by yourself

Action Execution

Select next route

1
The response is returned to the browser

Action to execute is chosen based on name via ActionNameSelectorAttrlbute

Action to execute is chosen based on other logic via ActionMethodSelectorAttrlbute

Result Execution
Result Filters (OnResultExecuted ) are executed IValidateObject Model Binder de-serializes parameters Validation logic

View rendering
Model Validation Provider Retrieves validation rules Validation rules

Model Binder validates parameters

Authorization Filters

are executed

Html Helper, AjaxHelper , UrIHelper generate needed HTML code

Validation rules

ActionResult custom execution

Javascript validation logic is added

11
Model Validation Provider Retrieves model visualization info

is authorized?

Filters

Yes

HtmlHelper Templated Helper renders HTML of forms

Validation rules

Action Filters (OnActlonExecuting ) are executed

DependencyResolver finds and create instance of Filters Filters

IFilterProvlder finds filters applied to Action

template TemplateHelper templates No

IView

10

Execution stopped?

DependencyResolver finds and create instance of I View

All IVIewEngine registered are probed to find the view to render

9
Yes

No Filters

Action parameters are filled with values

ViewResult

8
Action is executed

Other Kind

What kind of ActionResult ?

Result Filters (OnResultExecuting ) are executed

ActionResult

Action Filters (OnActlonExecuted ) are executed

Filters Filters

Note: All the extensibility points are in bold For clarity, the DependencyResolver is in 3 different boxes, because it retrieves 3 different types of objects, but it is always the same object. All the "helper objects' (the dependency resolver , the various providers etc) are outside the main execution flow to show their status as helpers to the main process.

Simple Talk September 2011

Anda mungkin juga menyukai