Slide 1: ASP.NET Overview Brian Hitney Developer Evangelist
http://www.structuretoobig.com Agenda : Agenda ASP.NET Environment
Project Setup / Compilation model / Configuration
User Controls/Server Controls
New features in ASP.NET
Deployment Projects Working with Projects – VS2003 : Working with Projects – VS2003 VS2003: Single solution file. Project precompiled into a single DLL, ASPX markup pages deployed.
Compiles/debugs like other projects (WinForms, etc.)
Slightly more efficient.
Single file deployment + referenced DLLs + HTML.
Not easy to use in team environments.
Often leads to monolithic DLLs for large sites. Working with Projects - VS2005 : Working with Projects - VS2005 VS2005: Website Compilation Model – All files compiled on demand.
Works better in teams.
Easy to deploy/test incremental updates.
Can be difficult to upgrade from VS2003.
First hit incurs compilation overhead.
May mean more files to deploy.
Web Application Projects – VS2005 add on to enable old style of building web applications. Working with Projects - VS2008 : Working with Projects - VS2008 VS2008: Both models supported out of the box. File -> New -> Project
-> ASP.NET Web App File -> New -> Web Site Old style New style WebForms in a Nutshell : WebForms in a Nutshell ASPX pages handled by a handler that facilitate the page lifecycle and events (such as Page_Load, PreRender, and control events).
Uses ViewState to encoded state-specific information otherwise lost in the stateless nature of HTTP.
Extensive controls library to abstract functionality. Buttons, textboxes, etc.
Can be difficult to manage many events with page lifecycle.
Do you load data in Init, Load, or event handlers?
How do you handle changes?
Developers still need to fully understand request/response nature of the web. Server Controls : Server Controls Typically compiled into a DLL.
Represents a small piece of functionality, like a textbox or button.
Responsible for handling any special rendering requirements, raising events, etc. Properties Event Handlers User Controls : User Controls Collections of HTML and/or Server Controls for a broader purpose – such as a login dialog box.
Typically part of a project and compiled with the project.
Can expose properties.
Part of the page lifecycle (OnInit, Page_Load, Prerender, etc.) Master Pages : Master Pages Same look and feel to many pages; code in one spot. Demo : Demo Server Controls
Master Pages Session Management : Session Management InProc
SqlServer Authentication & Authorization : Authentication & Authorization Originally, IIS configured via Anon/Basic/Integrated and explicit file ACLs.
ASP.NET introduced authorization/roles to resources via web.config setting.
Works only for pages handled by ASP.NET ISAPI. Authentication & Authorization : Authentication & Authorization Forms based authentication model
Provides an abstraction to maintaining user state
Done using an authorization ticket in an HTTP Cookie
You write the code to handle login, new users, etc., Forms Auth handles the client. Authentication & Authorization : Authentication & Authorization ASP.NET 2.0 and Up: Membership and Role Providers
Supports SQL Server or Active Directory
For SQL Server, handles password hashing, minimum password and strength, etc.
Easily pluggable into Forms auth (or custom auth)
Extensible – easy to author your own Membership provider by inheriting from the base class.
Source code available. ASP.NET Diagnostics : ASP.NET Diagnostics Advanced Tracing
Debugging Tracing : Tracing System.Diagnostics.Trace
Trace.Write (various Overloads)
11 Sections of Request Information Logged
Page Level Tracing
Allows you to designate on a page by page basis
Set in the Web.Config File
Page Level supersedes Web.Config settings View Trace Data : View Trace Data Multiple Pages at Once
Great for troubleshooting an application without user’s knowledge
Served by a custom HttpHandler
Output for the Specific Page
Appended to the Bottom of the normal output
Only shows data for specific request Health Monitoring : Health Monitoring Enables You to Log Web Events
Event Data Can Be Sent to Specific Stores
Can Be Extended Through the Provider Model
Configured in the Web.Config Debugging : Debugging Set Break Points on Specific Lines of Code with F9
Can Attach to a Running Process
Rich Set of DataTips
Nested Master Pages
Enhanced CSS Management
New data controls.
MUCH improved designer. Advanced Topics : Advanced Topics HttpHandlers and HttpModules
Web Deployment Projects
Custom Configuration HttpHandlers & HttpModules : HttpHandlers & HttpModules HttpHandlers : HttpHandlers Every request in ASP.NET is processed by an HttpHandler
For example, ASPX pages are handled by the default ASPX Page HttpHandler.
You can create your own httpHandlers to render content based on the request
Handlers process the incoming request and generate the response output.
Can be directly plugged in IIS7 (no more registering extensions to the ISAPI ASP.NET DLL). HttpModules : HttpModules HttpModules are Similar to ISAPI Filters
They are built using .NET
The Integrate with the ASP.NET Request Pipeline
The Pipeline is over 20 events that fire during the processing of a request.
Used to ‘Catch’ the Request and React as needed.
Logging Registering Handlers and Modules : Registering Handlers and Modules Caching: Entire Page or User Controls : Caching: Entire Page or User Controls Functionally equivalent… But! “Private” cache, clients unaware. Caching Data/Objects : Caching Data/Objects Far more powerful
Can tie into SQL Server for data change notifications.
Easier to Control Caching Client Side: Content Expiration : Caching Client Side: Content Expiration Covered later in IIS section, however:
Useful for static content to decrease load times – fewer requests.
Tells clients to “bugger off” for specified time.**
Essentially a “public” cache. Caching Client Side : Caching Client Side Etags and IF-MODIFIED-SINCE
Client requests resource each request. (Can be configured via Max-Age setting.)
If not changed, send 304 Not Modified response.
Still requires round trip, but saves bandwidth. Demo : Demo Caching page level
Caching data and objects Web Deployment Projects : Web Deployment Projects Offers options for build/deployment tasks, including Precomplilation.
Choose to compile all resources, or leave as-is. Custom Configuration Sections : Custom Configuration Sections Can add Custom Configuration Sections to Web.Config
Much more extensible than appSettings Q&A and Lab : Q&A and Lab