Title: ASP'NET Internals
1ASP.NET Internals
Dan.Amiga_at_develop.com 972-52-3030304
2Disclaimer
3Game plan
- Understanding and utilizing ASP.NET
- Goal Leave you with a solid end-to-end
understanding the ASP.NET Pipeline
4W3WP.EXE
ASP.NET ISAPI
http.sys
AppDomain
HttpRuntime
HTTP
CONENT
HttpApplicationFactory
HttpApplication
HttpContext
e
e
HttpModule
PageHandlerFactory
PageHandler
5Dynamic web content
- Dynamic content over a stateless protocol
- Dynamically generated HTML requires server host
and a supporting engine - Engines include CGI,ISAPI,ASP,ASP.NET
- ASP.NET custom host
- Cassini, VS Development server.
6(No Transcript)
7ASP.NET on IIS 6.0
- IIS6
- AppPool model
- Limited customization
- ASP.NET
- ISAPI Extension
- Only processes ASP.NET requests
8ASP.NET on IIS 7.0
- ASP.NET Modes
- ISAPI mode (compat)
- Integrated mode
- ASP.NET HttpModules plug directly into server
- HttpModules or Global.asax events can run code on
all requests - VB and C code can be easily used to customize
and extend the server
9.NET Runtime host
- What is a .NET runtime host?
- What does it mean to be a runtime host?
- Who can be a runtime host?
10W3WP.EXE
http.sys
.NET Runtime ASP.NET
SQL Server
.NET Runtime
Window Application
.NET runtime and ASP.NET
Everyone can be .NET Runtime host ASP.NET host
11ASP.NET runtime
- ASP.NET is an extensible HTTP processing
architecture - System.Web.Hosting.ISAPIRuntime
- HttpRuntime for host interaction
- HttpApplication for managing requests
- HttpContext ECB a like
- Request,Response,Session,Cache,User
12Request from host
AppDomain
Pool
HttpRuntime
HttpApplication
HttpApplication
HttpApplication
HttpApplication
HttpApplication
HttpApplicationFactory
HttpApplication
HttpContext
HttpContext
ASP.NET Runtime
13Handlers
- Code that responds to a request for a specific
URL - Responsible for generating HTTP response
- Implement IHttpHandler
- ASPX pages implement IHttpHandler
- Asynchronous Handlers
14Http Handler
BeginRequest()
HttpApplication
AuthenticateRequest()
Init
AuthorizeRequest()
HttpModule
HttpModule
ResolveRequestCache()
HttpModule
AcquireRequestState()
HttpModule
HttpModule
PreRequestHandlerExecute()
HttpModule
HttpModule
PostRequestHandlerExecute()
HttpModule
ReleaseRequestState()
UpdateRequestCache()
EndRequest()
IHttpHandler
15Asynchornous Handlers
Worker thread pool
QueueUserWorkItem
IO thread pool
HttpApplication
cb()
EndProcessRequest()
Async I/O
EndRead()
Stream
BeginProcessRequest(AsyncCallBack cb)
BeginRead(cb)
16Handler factories
- Allows custom initialization of handlers
- Used by ASP.NET to demand compile pages
- Implement IHttpHandlerFactory
- Great extensibility mechanism
- Combined with PageParser
- Examples
- PageHandlerFactory (VirtualPath)
- HttpRemotingHandlerFactory
- WebServiceHandlerFactory (syncSessionHandler)
17HttpApplication
PageHandlerFactory
PageHandler1
PageHandler2
18Virtual Path Providers
- Processing requests requires an endpoint
- typically endpoint is ASPX from the file system
- Virtual path providers allow virtualization of
file system - allows for alternate store of pages or any file
- typical use is DB store for website files and/or
content - Must provide classes that represents files or
directories
19HttpApplication
Virtual Path Providers
Virtual Path Providers
Virtual Path Providers
Virtual Path Providers
PageHandlerFactory
PageHandler1
PageHandler2
20HttpModules
- Handle events for pre/post processing
- Before After handler is executed
- Always executes with HttpContext in scope
- Can choose to halt request processing
21HTTP Modules
HttpContext
BeginRequest()
HttpApplication
AuthenticateRequest()
Init
AuthorizeRequest()
HttpModule
HttpModule
ResolveRequestCache()
HttpModule
AcquireRequestState()
HttpModule
HttpModule
PreRequestHandlerExecute()
HttpModule
HttpModule
PostRequestHandlerExecute()
HttpModule
ReleaseRequestState()
UpdateRequestCache()
EndRequest()
PageHandler/Factory
22Summary
W3WP.EXE
ASP.NET ISAPI
http.sys
AppDomain
HttpRuntime
HTTP
CONENT
HttpApplicationFactory
HttpApplication
HttpContext
e
e
HttpModule
PageHandlerFactory
PageHandler
The entire HTTP Pipeline
23ASP.NET Internals
Dan.Amiga_at_develop.com 972-52-3030304
24ASP.NET Internals
Dan Amiga Senior Consultant, Advantech Instructor,
DevelopMentor http//blogs.microsoft.co.il/amiga
dan_at_advantech.co.il Dan.amiga_at_develop.com
25Compilation
- Explain page compilation
- Demand compilation
- BuildProviders
- CompilationMode Never
- No code but Eval,Bind,ExpressionBuilders apply
26Build Providers
27System.Web.UI.Page
Partial class files compiled into a single class
Framework Generated file
Your code behind
ASPX Page Markup