Title: ASP'NET Application Framework
1ASP.NET Application Framework
- Sean Puffett
- Developer Evangelist
- Microsoft UK
- seanpuff_at_microsoft.com
2Agenda
- Caching
- Data Binding
- Session State
- Configuration
- Authentication Security
- Deployment
3Caching
- Full page output caching
- Vary by params, language, user-agent
- Fragment Caching
- Enables portions of pages to be cached
- Extensible Cache API
- Developers can cache arbitrary objects
- Multiple expiration policies, file change
invalidation
4Caching - Additional Topics
- Page Output Caching
- lt_at_ OutputCache Duration"60" gt
- Page Data Caching
- CacheMyDataSet SomeDataSet
- Like Application Variables
- Scavenging
- Expiration
- Dependencies
5 demo
Simple Fragment Caching
6Data Binding
- Provides a simple, declarative way to bind Web UI
elements to data - Simple binding to a single property
- Or directly into the page
- List binding to a data source
- DataGrid, DropDownList, etc.
- Huge variety of data sources supported
- But One way snapshot model
- Requires code to update the data source
7Simple Binding Syntax
- Step 1 Set bindings
- Declaratively (in HTML)
- ltaspLabel Textlt custID gt /gt
- Step 2 Call DataBind
- Sub Page_Load(s As Object, e As EventArgs)
Label1.DataBind() - End Sub
8Simple Binding Example
- lt_at_ Page languageVB gt
- ltscript runatservergt
- Sub Page_Load(s as Object, e as EventArgs)
- Label1.DataBind()
- End Sub
- lt/scriptgt
- lthtmlgt
- ltbodygt
- ltaspLabel idLabel1 runatserver Textlt
DateTime.Now gt /gt - lt/bodygt
- lt/htmlgt
9Binding Data To Lists
- DataGrid, DropDownList, etc.
- Supported DataSources
- ADO.NET Connected DataReader
- ADO.NET Cached
- DataSet, DataTable, DataView
- Also other IEnumerable types
- ArrayList, Array
- Hashtable
- Result of a method
10List Binding Syntax
- Step 1 Set bindings
- Declaratively (in HTML)
- ltaspDataGrid DataSourcelt ds gt /gt
- Imperatively (in code)
- DataGrid1.DataSourceds
- Step 2 Call DataBind
- Sub Page_Load(s As Object, e As EventArgs)
DataGrid1.DataBind() - End Sub
11 demo
Data Binding A DataGrid Control
12Session State
- 3 Modes of Session State
- In-Proc
- Stores values in the memory of the ASP.NET Worker
Process - StateServer
- Uses a Microsoft Windows Service to store Session
Variables - SqlServer
- Uses one or more SQL Servers to store Session
Variables
13Session Variables
- Store state information
- No longer require Cookies
- Share between servers
- ltsessionstate
- inproc"false"
- serverAnotherServer"
- port"42424"
- /gt
14Scale-Out Web Architecture
- Session state supports web farms
- Applications no longer tied to one machine
- Single state server supports multiple app servers
- Multiple Session State providers
- ASP.NET state server
- SQL Server
15 demo
In-Proc Session State
16Configuration
- Stored in XML file in directory with pages
- web.config
- Contains all ASP.NET settings
- Authentication, compile options, custom error
pages, etc. - Allows adding Application settings
- DSN, etc.
- Extensible
- Can extend with custom configuration data
- Overrides/Adds to settings in machine.config
17IBuySpy Configuration
ltconfigurationgt ltappSettingsgt ltadd
key"DSN" valuedata sourceibs2Trusted_Connecti
onyes" /gt lt/appSettingsgt ltlocation
path"CheckOut.aspx"gt ltsystem.webgt
ltauthorizationgt ltdeny users"?" /gt
lt/authorizationgt lt/system.webgt
lt/locationgt ltsystem.webgt ltauthentication
mode"Forms"gt ltforms name"IBuySpyAuth"
loginUrl"Login.aspx" protection"all"gt
lt/authenticationgt ltcustomErrors
mode"RemoteOnly" defaultRedirect"ErrorPage.aspx"
/gt lt/system.webgt lt/configurationgt
ltappSettingsgt ltadd key"DSN" value"data
sourceibs2Trusted_Connectionyes" /gt
lt/appSettingsgt
ltlocation path"CheckOut.aspx"gt
ltsystem.webgt ltauthorizationgt
ltdeny users"?" /gt lt/authorizationgt
lt/system.webgt lt/locationgt
ltauthentication mode"Forms"gt ltforms
name"IBuySpyAuth" loginUrl"Login.aspx
protection"allgt lt/authenticationgt
ltcustomErrors mode"RemoteOnly"
defaultRedirect"ErrorPage.aspx"/gt
18ASP.NET Authorisation
- Basic, Digest and NTLM leverage IIS
- Credential verification against Active Directory
- Passport module provided
- Exposes passport profile API
- Custom, forms-based authentication
- Easy to use, with cookie token tracking
- Custom login screen (no popup dialogs)
- Credential checks against database, etc.
19 demo
Introducing Forms Authentication
20Deployment - with ASP
- DLL Locking
- Page hit
- Shutdown web application
- Shutdown Internet information Server
- Edit in Visual Interdev
- MTS/COM
- Shutdown package
- Binary compatibility
- Registry
21Deployment - with .NET
- XCopy Deployment
- Components in .\bin
- No registration required for components
- No Locked DLLs (Server stop not required)
- Supports all web resources
- Web pages, web services
- Compiled components (DLL)
- Configuration files
22Deployment - continued
- Update running apps
- Simply copy DLL on top of old ones
- Application gracefully migrated to new code
- Old application stopped when all users have
closed the session - Applications are Isolated
- Each application can have its own version
- Uninstall
- Delete
23 demo
Replacing A Running Assembly
24Summary
- Caching
- Data Binding
- Session State
- Configuration
- Authentication Security
- Deployment
25Useful Resources
- Walkthrough Using a DataGrid Web Control to Read
and Write Data - http//msdn.microsoft.com/library/default.asp?url
/library/en-us/vbcon/html/vbwlkwalkthroughusingdat
agridwebcontroltoreadwritedata.asp - INFO ASP.NET State Management Overview
- http//support.microsoft.com/?id307598
- Book Essential ASP.NET by Fritz Onion
- (ISBN 0-201-76039-8)
26Additional Information
- Post Events Site
- All information on past events, slide decks etc
- http//www.microsoft.com/uk/msdn/postevents
- The UK MSDN Site Flash
- Local news, events, webcasts
- http//www.microsoft.com/uk/msdn
- Register to received the bi-weekly MSDN Flash by
email - http//www.microsoft.com/uk/msdn/flash.aspx
- GotDotNet and ASP.NET lots of excellent
resources - http//www.gotdotnet.com
- http//www.asp.net