Active Server Page Processing and the World Wide Web
-
Upload
ivory-bauer -
Category
Documents
-
view
31 -
download
5
description
Transcript of Active Server Page Processing and the World Wide Web
We will look at…Sometimes web development is just plain
weird!
Internet / World Wide WebAspects of their operationThe role of clients and servers
ASPX Page (Web Form)How it is passed between browser and serverThe structure of the pageHow it provides functionality to the browser
The problem of state
The Internet and TCP/IP
Network of networks Defence research in the 60sTCP/IP (Transmission Control Protocol /
Internet Protocol)Allows programs on computers to talk to
each other
The IP AddressUniquely identifies each machine32 bit number made up of four 8 bit numbers Visit http://209.85.227.105/
Assigned in blocks
www.dmu.ac.uk 146.227.160.79www.cse.dmu.ac.uk 146.227.57.2G677 (my server) 146.227.53.94
PortsTCP/IP allows programs on machines to
communicateIP address identifies machineport number identifies programThere is no law that states a specific port must be
used for a service however there are certain ports that traditionally provide services.
80 HTTP (web pages)21 FTP (File transfers)119 NNTP (Network News Transfer Protocol)443 HTTPS (secure web pages)
The Good Old DaysUp until about 1989 the Internet existed
quite happily without the World Wide Web
File Transfer Protocol (FTP) TelnetUsenet
World Wide Web - Is not the internet!
Server v Client Side CodeCode may be added at either end of the process
Client side code runs at browserAction Script (Flash)JavaScript VBScript
Server Side CodeASP.NET (C # VB.NET)PHPJSP
HTML Form Code
Change POST to GET
http://g519-md.ad.cse.dmu.ac.uk/Request/?txtFirstName=Matthew&txtLastName=Dean&Submit1=submit
Active Server Pages (ASPX)Events & Handlers User triggered events
Click Triggered when a user presses a button
Selected Index Changed Activated when the user selects an item off a drop down list
System generated
Load Runs when the ASPX page is loaded by the server
Unload Runs when the ASPX page is unloaded from the server
Post Back = FalsePost back is false on the first HTTP request
The browser sends the request to the server for the page
The server runs the page load eventThe server runs page unload eventASPX controls converted to HTML and sent to
the requesting browser
Post Back = True
The browser sends the HTTP request to the server
The server runs the page load eventThe server runs other events (in this case the
click event of the Go button)The server runs the page unload eventAll asp controls changed into suitable HTML
controls and sent back to the requesting browser
NOTE Load and Unload Events ALWAYS RUN!
The Problem of State We have seen the following points
The web follows a client server mode of operation The ASPX page is rendered on the server and sent to the browser as HTML The page is rendered in two modes
PostBack = False
(The first time the page is requested, Load – Unload events) PostBack = True
(Subsequent renderings of the page, Load – Other Events – Unload)
The thing to note in all of this messing about is that the settings of
the page are not automatically remembered on each round trip. The web is referred to as stateless.
So how is this problem addressed?
Use CookiesCookies are small files stored on the client
computer that allow the web page to record details of its visit to that machine.
Cookies may be turned off by the user of the
client machine.
Not suitable for sensitive data.
Use a Query String
This is achieved by setting the HTML forms method to Get rather than Post.
This is a good technique so long as the data isn’t a
potential security risk. This would be a very bad query string. http://www.mysite.com/login.asp?
UserName=Fred&Password=password123
Use Session Variables
Use in conjunction with IsPostBack in the Load Event of the page…
Browser Server
HTTP Request
HTML Page
Load session variables in the load event
Save session variables in the unload event
Potential Problem…Remember the load event runs every time the page is
processed and it is the first thing the server does. If we load the messages on subsequent renderings of the
page we get the following problem…
I click an entry in the list and press delete The load event runs re-setting the list removing my selection The delete click event fails because the list has been re-set
To avoid this kind of problem we need to check IsPostBack
to see if it is appropriate to read data at the server.