HTTP Runtime
• A low-level HTTP processing infrastructure
• Logical replacement for ISAPI filters/extensions
• Ability to add, replace, or remove core pieces of
the product
• Benefits: Built-in thread pool, asynchronous
support, access to ASP.NET intrinsic objects
HTTP Modules
• Called before and after the handler executes
• Ability to intercept, participate or modify each
individual request into an application
Ex: Changing URL in request/response to hide
server names behind firewall.
• The HTTP Application provides several events
that modules can synchronize with
HTTP Modules
• Global Application Events:
– Start
– End
• Per request events (in order):
– BeginRequest – PreRequestHandlerExecute
– AuthenticateRequest – PostRequestHandlerExecute
– AuthorizeRequest – ReleaseRequestState
– ResolveRequestCache – UpdateRequestCache
– AcquireRequestState – EndRequest
• Per request events (non-deterministic):
– PreSendRequestHeaders
– PreSendRequestContent
– Error
HTTP Handlers
• Handlers:
– Are the endpoint in the request process
– Only one handler is invoked per request
• Examples
– ASP.NET Page Handler:
• Implements the ASP.NET Page Framework
• Processes all requests for .aspx pages
– ASP.NET Service Handler:
• Implements Web Services
• Processes all requests for .asmx pages
• Configuring HTTP Handlers
HTTP Handlers & Modules
HTTP Context
• Encapsulates all information about an individual
HTTP request
• ASP.NET intrinsic objects are exposed as properties
of the HttpContext
• Modules and Handlers get a reference to an
HttpContext object representing the current
request
• Flows through the lifetime of a request
HTTP Context
• ASP.NET supports all ASP classic members
Property Managed Class
– Request HttpRequest
– Response HttpResponse
– Server HttpServerUtility
– Session HttpSessionState
– Application HttpApplicationState
• ASP.NET adds several new and useful members
– Request.Files
– Response.Cache
– Error/User/Trace
Global.asax
• Extends on the familiar functionality of the
Global.asa
• Global.asax must be located in the root of a Web
application
• Enables easy handling of Application level events
without a custom HttpModule
Global.asax
Updates:
• Are automatically detected
• Causes the Global.asax to be recompiled
• Restarts the HTTP Application
• ASP.NET completes all current requests before
shutting down old application
• Fires Application_End event
• Shuts down App Domain
HTTP Context & Global.asax
Page Framework
• Overview
• Page Object
• Page Lifecycle
• Page Events
• Control Tree
• Page Directives
Page Framework
Page Object:
• Inherits from Control, implements IHttpHandler
• All .aspx pages inherit from Page
• Exposes the ASP.NET intrinsics
• Wires up events (Page_Load, Page_Init…)
0 comments
Post a comment