Java Web Development Basics - State Management

ASP.NET Control Flow
SoftUni Team
Technical Trainers
Software University
http://softuni.bg
Have a Question?
sli.do
#CSharpWeb
2
Table of Contents
1. Request Life Cycle
2. Http Handlers
3. Http Modules
4. Handlers vs Modules
5. MvcRouteHandler
3
Request Life Cycle
Life of Application
HttpApplication
MvcApplication
Routing
App Start
MVC Generates
Response
App End
Request Lifecycle
Routing
Request
URL Routing Module
MVC Route Handler
MVC HttpHandler
Controller Initialization
Controller Factory
Dependency Resolution
Action Execution
Model Binding
Action filters
(action executing)
Action Execution
Result Execution
Result Filter
(Result
Executed)
Response
View Engine
Find and
Render View
Other ActionResult
Result Execution
ResultFilter
(Result Executing)
Invoke Action Result
Action Filters
(action executed)
Action Result
Application Lifecycle
Live Demo
7
Http Handlers
HttpHandlers
 Classes that implement IHttpHandler
 They generate a response to an HttpRequest
HttpHandlers and Request Life Cycle
ASP.NET HttpHandler
Selection
HttpHandler Executes
10
Creating an HttpHandler
 Create a class that implements the IHttpHandler interface
 Register the HttpHandler through code or config file
 IHttpHandler exposes two members:
 IsReusable
 ProcessRequest()
11
Common Uses
 Customizing behavior of existing frameworks
 Building your own framework
12
Building a Custom HttpHandler
Live Demo
13
Http Modules
HTTP Modules
 Classes that implement IHttpModule
 They are designed to respond to Life Cycle Events
HttpModules and Request Life Cycle
HttpModule 1
HttpModule 2
HttpModule 3
16
Advantages of HttpModule
Applications
Global.asax
Reusable
HttpModule
17
Creating and HttpModule
 Implement the IHttpModule interface
 Register the HttpModule through code or config file
 IHttpModule exposes two members:
 Init()
 Dispose()
18
HttpModules and HttpContext
HttpContext
HttpModule
MVC Framework
Execution
HttpModule
19
Creating a Custom HTTPModule
Live Demo
20
Handlers vs Modules
Comparing Modules and Handlers
Modules
Many HttpModules can
service one request
Handlers
Only one HttpHandler can
service a request
Comparing Modules and Handlers (2)
Modules
Handlers
Modify and support requests
through services
Generate the response that
is sent back to the browser
Comparing Modules and Handlers (3)
Modules
Handlers
IHttpModule
IHttpHandler
Comparing Modules and Handlers (4)
Modules
Register through
code or web.config
Handlers
Register through
code or web.config
Comparing Modules and Handlers (5)
Modules
Handlers
Designed to integrate with
of the Life Cycle Events
Concerned with the event related
to handler mapping and execution
MvcRouteHandler
MvcRouteHandler and MvcHandler
UrlRoutingModule
1.
2.
3.
4.
Match Url to Route defined in MVC app
Get the Route's MvcRouteHandler
CallGetHttpHandler on MvcRouteHandler
Call ProcessRequest on returned
MvcHandler
MvcHandler Execution
28
Summary
 HttpHandlers generate a response for a request
 HttpModules respond to Life Cycle Events to provide services and
manipulate the request
 MvcHandler is the MVC framework’s implementation of
IHttpHandler
29
ASP.NET Control Flow
?
https://softuni.bg/courses/
License
 This course (slides, examples, demos, videos, homework, etc.)
is licensed under the "Creative Commons AttributionNonCommercial-ShareAlike 4.0 International" license
31
Free Trainings @ Software University
 Software University Foundation – softuni.org
 Software University – High-Quality Education,
Profession and Job for Software Developers

softuni.bg
 Software University @ Facebook

facebook.com/SoftwareUniversity
 Software University @ YouTube

youtube.com/SoftwareUniversity
 Software University Forums – forum.softuni.bg