ASP.
NET
Fraser Gallop
Microsoft Student Consultant
University of Alberta
The 5 Pillars of .NET
Devices
PocketPC, Cell Phones, Desktop, WebTV
Web Services Enterprise Servers
XML, SOAP, ASP.NET
Development Tools
.NET Framework
Operating System
Heading towards a new
model for the Internet
XML
Web Web
Service Service
XML
XML
Web Web
Service Service
“Building
Client Block
Client
Device Device Services”
XML
3
Pre-ASP Era
In the old days…
1. Send a request to
the server
2. Receive a reply
containing the Client
requested data
Server 4
Entering the ASP Era
What did we want?
Dynamically generated HTML pages
Program logic to generate pages
Ability to receive data from the user and
write output to the browser
Security—keep unauthorized people out,
and prevent people from doing things
they should not
Ability to manage user sessions
5
The ASP Era
A Web server run-time environment
that was easy to use for simple tasks
Allowed for dynamic generation of
content when the page was loaded
Server side executable code
Code directly embedded in the HTML files
<p><%=now%></p>
Write some HTML here.
<% Response.Write(“hello”) %>
<h3>how are you <%=Request.Form(“username”)%>?</h3>
6
Upsides to ASP
Server side includes
Component Building model
Server side access to databases
Use of Visual Basic or JavaScript
ODBC Link to any data source
Scripting embedded into the HTML
pages
7
Downsides to ASP
Tied tightly into IIS
Not Really Cross-platform
Solutions
exists for Apache & Linux
Not easy to implement
Can only use Visual Basic or Java
Script Language – must be interpreted
8
A New Era – ASP.NET
A complete rewrite of the original ASP
Kept the best concepts
Detangles your code from the HTML
Separates the programming logic from
the look of the page
Program in ANY
.NET language
Better tools, debugging WOW!
9
New Features in ASP.NET
Pre-fabricated controls
Similar to Windows controls
Built-in security mechanisms
Web farmable session management
Just-in-time compilation
No server restarts required
Settings stored in XML
10
Web Controls Function
Text display
Name
Label
Text edit TextBox
Selection from a list DropDownList
Encapsulate reusable ListBox
Graphics Display Image
program logic AdRotator
Deal with the user Value setting CheckBox
interface RadioButton
Date setting Calendar
Richer, more Commands Button
numerous, and easier LinkButton
than standard HTML ImageButton
Navigation controls HyperLink
controls Table controls Table
Render their own TableCell
TableRow
HTML for the client Grouping other controls CheckBoxList
Detect the capabilities Panel
of the browser being RadioButtonList
used List controls Repeater
DataList
Maintain their state DataGrid
11
Page execution engine
1. .ASPX page request 2. Request forwarded
from client to execution engine
IIS
3. Compiles .ASPX page first time
page is encountered.
.ASPX page
<asp: label> etc.
Execution engine
4. Loads compiled class and creates
Code-behind object code-behind object.
contains event handlers. 5. Code-behind object creates
controls and tells controls to render
themselves in HTML.
6. HTML returned to IIS.
12
The Web.config file
Configuration management for
ASP.NET
XML file
Hierarchical structure
Master system
machine.config
App A web.config App B web.config
App B subdir
web.config
13
State Management
Client Browser
Server
1. Client requests first page
Session ID cookie 2. Server receives request, creates
Session object, stores cookie on
4. Client requests second the client.
page, passing cookie.
3. Programmer stores data in Session object
7. Client receives second 5. Server transparently fetches
page based on what he Session object identified by cookie.
did on the first page.
6. Programmer fetches data from
Session object. It magically contains
Different requests from a the user’s right data.
single user may need to know
about each other
Need to maintain separate Sessions
data for many users at the
same time
User A’s User B’s
Deleted after a configurable data data
time interval
Can be stored in a separate Other users…
process, machine, or in a SQL
Server database
14
Security
Different areas of an application require different
levels of security
Does not provide data encryption
Authorization can be specified in the web.config file
Name Description
None Anonymous access to pages
Windows Standard Windows authentication from IIS (best for Windows-
only intranets)
Forms All page request headers contain a cookie issued by the server,
pages requested without the cookie are redirected to a login
page (best for sites with many users where issuing a Windows
account is not practical)
Passport Uses Microsoft’s external Passport authentication service (a
cool alternative to forms-based authentication)
15
Demonstration
An few examples of ASP.NET
Putting ASP.NET to work
Programmers will create applications
from services available on the Web
Everyday applications will have built-in
Internet access
We need technology that will
communicate with other technology
Find the lowest common denominator
On the Internet, it is HTML and XML
17