WEB322 WEB322 ASP.NET Internals: ASP.NET Internals: Under the Covers Under the Covers – – Exploring Internals, Exploring Internals, Page Page Lifecycle and Lifecycle and the the Compilation Model Compilation Model Simon Calvert Simon Calvert Program Manager Program Manager Web Platform and Tools Team Web Platform and Tools Team Microsoft Corporation Microsoft Corporation
27
Embed
WEB322 ASP.NET Internals: Under the Covers – Exploring Internals, Page Lifecycle and the Compilation Model Simon Calvert Program Manager Web Platform and.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
WEB322WEB322ASP.NET Internals: ASP.NET Internals: Under the Covers Under the Covers – Exploring – Exploring Internals, Internals, Page Lifecycle andPage Lifecycle and the the Compilation ModelCompilation Model
Simon CalvertSimon CalvertProgram ManagerProgram ManagerWeb Platform and Tools TeamWeb Platform and Tools TeamMicrosoft CorporationMicrosoft Corporation
AgendaAgenda
ASP.NET compilationASP.NET compilationDevelopment cycles and options:Development cycles and options:
Dynamic compilationDynamic compilation
Pre-compilationPre-compilation
Build extensibility Build extensibility
ASP.NET page lifecycleASP.NET page lifecycleCall backs, cross-page postCall backs, cross-page post
Asynchronous pagesAsynchronous pages
ASP.NET V2 Web ApplicationASP.NET V2 Web Application
Layout (xcopy, copy web, build)Layout (xcopy, copy web, build) ASPX …ASPX … : Allows changes : Allows changesCodeCode: Can remove. Changes rebuild App.DLL : Can remove. Changes rebuild App.DLL App.DLLApp.DLL: Pre-built or build: Pre-built or build
Runtime: ASP.NETRuntime: ASP.NETDynamic compilation of known ‘file’ typesDynamic compilation of known ‘file’ typesKnows ‘single-file’ onlyKnows ‘single-file’ only
System.Web.UI.Page
ASP.NET v1.x CompilationASP.NET v1.x CompilationPage CompilationPage Compilation
Class that the page-gen’ Class that the page-gen’ inherits frominherits from
Class that the page-gen’ Class that the page-gen’ inherits frominherits from
An (optional) class-name An (optional) class-name for the page-gen’ classfor the page-gen’ class
An (optional) class-name An (optional) class-name for the page-gen’ classfor the page-gen’ class
namespace App1 { public class WF1 : System.Web.UI.Page { .. } }
Base class. Final base is System.Web.UI.PageBase class. Final base is System.Web.UI.PageBase class. Final base is System.Web.UI.PageBase class. Final base is System.Web.UI.PageCode behind class. Namespace Code behind class. Namespace driven by project and folder (C#). driven by project and folder (C#).
Code behind class. Namespace Code behind class. Namespace driven by project and folder (C#). driven by project and folder (C#).
DLLDLLDesign-time: VSDesign-time: VSPagesPages: Code-behind : Code-behind or single fileor single fileControlControl: No code ‘spit’: No code ‘spit’
ASP.NET v2ASP.NET v2Development CyclesDevelopment Cycles
Design & DevelopDesign & DevelopASPX …ASPX …
WSDL, XSD, RESXWSDL, XSD, RESXCS/VBCS/VB
DLLDLL
Runtime: ASP.NETRuntime: ASP.NETDynamic compilation of file ‘types’, (extensible)Dynamic compilation of file ‘types’, (extensible)Compilation of specialized foldersCompilation of specialized folders
Auto-generated partial class
Default2
Partial class defined in codefile
Default2
Auto-generated page class
MyClass2
Auto-generated page class
MyClass
Auto-generated partial class
_Default
Partial class defined in codefile
_Default System.Web.UI.Page
Dynamic compile
ASP.NET v2 CompilationASP.NET v2 CompilationPage CompilationPage Compilation
Class that the page-gen Class that the page-gen inherits frominherits from
Class that the page-gen Class that the page-gen inherits frominherits from
An (optional) class-name An (optional) class-name for the page-gen classfor the page-gen class
An (optional) class-name An (optional) class-name for the page-gen classfor the page-gen class
public partial class _Default : System.Web.UI.Page
Class is ‘partial’. Combined to Class is ‘partial’. Combined to auto-gen’ partial classauto-gen’ partial class
Class is ‘partial’. Combined to Class is ‘partial’. Combined to auto-gen’ partial classauto-gen’ partial class
Base Class. Final base is System.Web.UI.PageBase Class. Final base is System.Web.UI.PageBase Class. Final base is System.Web.UI.PageBase Class. Final base is System.Web.UI.Page
ASP.NET v2 Code-Behind ASP.NET v2 Code-Behind and Compilationand Compilation
ASP.NET v2 CompilationASP.NET v2 CompilationSpecialized FoldersSpecialized Folders
Bus’ Logic, Base & Utility Classes ..Bus’ Logic, Base & Utility Classes ..Compile assembly (or many in order Compile assembly (or many in order
in <codeSubDirectories>)in <codeSubDirectories>)1.1. Single language per folderSingle language per folder2.2. Can contain ‘non-code’ typesCan contain ‘non-code’ types
\App_GlobalResources\App_GlobalResources
Global ResourcesGlobal Resources1.1. Strongly-typed resourcesStrongly-typed resources2.2. Shared in applicationShared in application
\App_WebReferences\App_WebReferences
Web Service ReferencesWeb Service References1.1. Folder structure defines typeFolder structure defines type2.2. Dynamic URL proxy generationDynamic URL proxy generation3.3. Consumable throughout Consumable throughout
applicationapplication \App_Browsers\App_Browsers
Browser CapabilitiesBrowser Capabilities1.1. .BROWSER files.BROWSER files2.2. Compiled on demandCompiled on demand
default.aspxdefault.aspx
\App_LocalResources\App_LocalResources
\App_Themes\Theme\App_Themes\Theme
Page compilationPage compilation1.1. Compiled on demandCompiled on demand2.2. Batching and dependenciesBatching and dependencies3.3. Local resources compiledLocal resources compiled4.4. Theme and master-pages Theme and master-pages
compiled on demandcompiled on demand
ASP.NET v2 Pre-compilationASP.NET v2 Pre-compilationScenariosScenarios
No ‘penalty’ for first-time request:No ‘penalty’ for first-time request:In-place pre-compilationIn-place pre-compilation
Deploy to a server:Deploy to a server:No ‘code’ or markup on the serverNo ‘code’ or markup on the server
Allow markup for minor changes, UI layoutAllow markup for minor changes, UI layout
Ship to a third party, IP restriction:Ship to a third party, IP restriction:Package deployed applicationPackage deployed application
ASP.NET v2 Build ExtensibilityASP.NET v2 Build ExtensibilityScenariosScenarios
File-based type extensibility: File-based type extensibility: Create custom types from arbitrary file Create custom types from arbitrary file types, e.g. XSD in types, e.g. XSD in \App_Code\App_Code
Create custom handlers, e.g. ASHXCreate custom handlers, e.g. ASHX
Create custom content, e.g. ASCXCreate custom content, e.g. ASCX
Non-file based source extensibility:Non-file based source extensibility:Move web content to a databaseMove web content to a database
CustomCustom BuildProvider and BuildProvider and VirtualPathProviderVirtualPathProvider
ASP.NET v2 Page Framework ASP.NET v2 Page Framework Page LifecyclePage Lifecycle
ASP.NET v2 Page FrameworkASP.NET v2 Page FrameworkAsynchronous Page ModelAsynchronous Page Model
3-tier web applications:3-tier web applications:Synchronous pages (v1.x, v2):Synchronous pages (v1.x, v2):
Remote resource (web service, database) is Remote resource (web service, database) is unresponsive threads are blocked unresponsive threads are blocked
Web application may be unresponsive Web application may be unresponsive
Asynchronous pages (v2):Asynchronous pages (v2):Create non-blocking call to access remote Create non-blocking call to access remote resources resources
Isolates issue to pages accessing remote Isolates issue to pages accessing remote resourcesresources
Potential to reduce # threads, improve latency Potential to reduce # threads, improve latency and throughputand throughput
ASP.NET v2 Page FrameworkASP.NET v2 Page FrameworkAsynchronous Page ModelAsynchronous Page Model
V1.x: Pages make sync (blocking) Web V1.x: Pages make sync (blocking) Web Service callsService calls
Can use Can use IHttpAsyncHandlerIHttpAsyncHandler (not a page)(not a page)
V2: New ‘event’ style async pattern V2: New ‘event’ style async pattern Simplifies making async callsSimplifies making async calls
V2: Pages can be async:V2: Pages can be async:‘‘Event’ or BeginXXXX/EndXXXX stylesEvent’ or BeginXXXX/EndXXXX styles
ASP.NET v2 Page FrameworkASP.NET v2 Page FrameworkAsynchronous Page ModelAsynchronous Page Model
Deploy no source codeDeploy no source code Pre-compilation (allow markup Pre-compilation (allow markup changes) and dynamic compilationchanges) and dynamic compilation
Deploy no source code or Deploy no source code or markupmarkup
Pre-compilation (no code or markup Pre-compilation (no code or markup changes)changes)
Deploy and release Deploy and release managementmanagement
Pre-compilation options for Pre-compilation options for fixednames, keyfile ..fixednames, keyfile ..
ResourcesResources
WEB320 ASP.NET Best Practices and Techniques for Migrating ASP.NET 1.x Applications to ASP.NET 2.0
WEB323/324 Overview of ASP.NET 2.0 (Part 1) and (Part2)
WEBC11 Q&A ASYNC, Compilation and other 500+ Level Topics With the Web Platform Development Team
Your FeedbackYour Feedbackis Important!is Important!Please Fill Out a Survey forPlease Fill Out a Survey forThis Session on CommNetThis Session on CommNet