1 / 25

Active Server Page Processing and the World Wide Web

Active Server Page Processing and the World Wide Web. The Problem of State. We will look at…. Sometimes web development is just plain weird! Internet / World Wide Web Aspects of their operation The role of clients and servers ASPX Page (Web Form)

ivory-bauer
Download Presentation

Active Server Page Processing and the World Wide Web

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Active Server Page Processing and the World Wide Web The Problem of State

  2. We will look at… • Sometimes web development is just plain weird! • Internet / World Wide Web • Aspects of their operation • The role of clients and servers • ASPX Page (Web Form) • How it is passed between browser and server • The structure of the page • How it provides functionality to the browser • The problem of state

  3. The Internet and TCP/IP • Network of networks • Defence research in the 60s • TCP/IP (Transmission Control Protocol / Internet Protocol) • Allows programs on computers to talk to each other

  4. The IP Address • Uniquely identifies each machine • 32 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.79 • www.cse.dmu.ac.uk 146.227.57.2 • G677 (my server) 146.227.53.94

  5. Name Servers • http://209.85.227.105/ not obviously www.google.com

  6. Ports • TCP/IP allows programs on machines to communicate • IP address identifies machine • port number identifies program • There 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)

  7. The Good Old Days • Up until about 1989 the Internet existed quite happily without the World Wide Web • File Transfer Protocol (FTP) • Telnet • Usenet • World Wide Web - Is not the internet!

  8. The Web’s Client Server Model

  9. Where is Client and Server in Visual Studio?

  10. Server v Client Side Code • Code may be added at either end of the process • Client side code runs at browser • Action Script (Flash) • JavaScript • VBScript • Server Side Code • ASP.NET (C # VB.NET) • PHP • JSP

  11. Server Side Code – Dynamic Pages

  12. HTML Forms GET and POST • HTML allows simple form creation

  13. HTML Form Code Change POST to GET http://g519-md.ad.cse.dmu.ac.uk/Request/?txtFirstName=Matthew&txtLastName=Dean&Submit1=submit

  14. 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

  15. Create a Similar Form in ASP

  16. Active Server Controls Note the tag <asp

  17. Post Back = False • Post 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 event • The server runs page unload event • ASPX controls converted to HTML and sent to the requesting browser

  18. What the Browser Gets… • ASP & Code never makes it to the browser!

  19. Post Back = True • The browser sends the HTTP request to the server • The server runs the page load event • The server runs other events (in this case the click event of the Go button) • The server runs the page unload event • All asp controls changed into suitable HTML controls and sent back to the requesting browser • NOTE Load and Unload Events ALWAYS RUN!

  20. 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?

  21. Use Cookies • Cookies 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.

  22. 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

  23. Load session variables in the load event HTTP Request Browser Server HTML Page Save session variables in the unload event Use Session Variables • Use in conjunction with IsPostBack in the Load Event of the page…

  24. 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.

  25. Summary • Because the web is stateless and processes pages the way that it does you will at some point get very confused about state! • Remember Load event runs first • Other Events next • Unload event last • Load and Unload always run!

More Related