You are on page 1of 1

Controller Creation

ASP.NET MVC Pipeline You are not going to enter the MVC
pipeline, you are on your own now
MvcHandler

the lifecycle of a request in ASP.NET MVC


by Simone Chiaretta Custom
3
MvcRouteHandler

Incoming request DependencyResolver


Controller finds and create
What type of
Factory instance
IRouteHandler ?
of Controller
Routing

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

No

ControllerActionInvoker
Action Execution
Select next route
Action to execute is chosen

1 based on name via


ActionNameSelectorAttrlbute

4
The response is
returned to the Action to execute is chosen
browser based on other logic via
ActionMethodSelectorAttrlbute

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

Model Binder validates parameters 5


View rendering
Model Validation Validation rules
Provider
Retrieves validation
rules Authorization Filters are executed
Html Helper,
AjaxHelper ,
UrIHelper generate
needed HTML code Validation rules

is
authorized?

ActionResult custom Javascript validation


11 Filters

execution logic is added

Yes
Model Validation
Provider
Validation rules Retrieves model
HtmlHelper DependencyResolver
visualization info IFilterProvlder
Templated Helper finds and create
renders HTML of
forms
6 Action Filters
(OnActlonExecuting ) are
instance
of Filters
finds filters
applied to Action
executed
Filters
template

TemplateHelper

IView
10 templates

Execution
No stopped?

DependencyResolver All IVIewEngine


finds and create registered are No
instance
of I View
probed to find the
view to render
9 Filters

Yes Action parameters are


filled with values
7
ViewResult
8
Action is executed

Result Filters
Other Kind What kind of
(OnResultExecuting ) Action Filters
ActionResult ? ActionResult (OnActlonExecuted )
are executed
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

You might also like