Professional Documents
Culture Documents
HttpApplication
Processing Pipeline
Controller
Creation
Routing
Authentication and
Authorization
MvcHandler
Model Binding Action Invocation
HTTP Response
Action Method (with Filters)
Invocation
Result Execution
(View, etc.)
ASP.NET MVC 5 APPLICATION LIFECYCLE – DETAIL VIEW
The diagram shows relevant HttpApplication stages to help you
understand where MVC integrates into the ASP.NET application Invoke authentication filters
HttpApplication lifecycle. In addition, for the overridable methods on the Controller (IAuthenticationFilter)
Processing Pipeline object that are part the MVC lifecycle, the diagram identifies when Start
HTTP Request Tasks to perform: these methods are invoked in the processing pipeline and why you
Common tasks such as register routes, bundles, and filters might want to override them. You may or may not have the need to Controller.OnAuthentication
Application_Start (in Global.asax.cs) Advance tasks such as set custom controller factory
override any one method, but It is important for you to understand
HttpApplication.Init
Override to subscribe to HttpApplication events their role in the application life cycle so that you can write code at If(AuthenticationContext.Result==null) false
HttpApplication the appropriate life cycle stage for the effect you intend. true
IHttpModule.Init
Processing Pipeline <IAuthenticationFilter1>.OnAuthentication
...
Retrieve MvcHandler as the HttpHandler Override to use a custom TempData provider. SessionStateTempDataProvider
Controller.CreateTempDataProvider
for the request (stored at is used by default.
HttpApplication.Context.Handler) Override to use a custom action invoker. AsyncControllerActionInvoker is used End
Controller.CreateActionInvoker
by default.
HttpApplication.BeginProcessRequest
Invoke authorization filters (IAuthorizationFilter)
(IAuthorizationFilter)
Start
HttpApplication.BeginProcessRequest
MvcHandler executes If(AuthorizationContext.Result==null) false
the controller action Controller.OnAuthorization
HttpApplication.EndProcessRequest
true
<IAuthorizationFilter1>.OnAuthorization
true
Controller.EndExecute
HttpApplication <IAuthorizationFilter2>.OnAuthorization
Execute action method with action filters (IActionFilter) Execute results with result filters (IResultFilter)
Start
Controller implements IResultFilter (by inheriting
Controller implements IActionFilter (by inheriting Controller.OnResultExecuting ActionFilterAttribute). OnResultExecuting methods
Controller.OnAuthenticationChallenge
Controller.OnActionExecuting ActionFilterAttribute). OnActionExecuting methods <ResultFilter1>.OnResultExecuting are executed in order before the result is executed.
<ActionFilter1>.OnActionExecuting are executed in order before the action method <ResultFilter2>.OnResultExecuting
itself. ... <IAuthenticationFilter1>.OnAuthenticationChallenge
<ActionFilter2>.OnActionExecuting
...
Asynchronous action methods (modified with the After authentication challenges are executed as a <IAuthenticationFilter2>.OnAuthenticationChallenge
Invoke action results
async keyword and returns Task<T>) are executed in (ActionResult.ExecuteResult) result of failed authentication or failed authorization,
<Named>Controller.<ActionAsync>
HttpApplication.BeginProcessRequest the result is executed immediately without any result ...
View, PartialView Other ActionResult
filters.
Controller.EndExecute Called in HttpApplication.EndProcessRequest to end types
HttpApplication.EndProcessRequest