2 1_WebApplicationDevelopment
jason.zhu edited this page 2021-05-11 09:45:44 +10:00

1. Web Application Development

1.1 Introduction

Overview of this chapter:

  • Client-server model.
  • .NET Framework
  • ASP.NET and C# Programming
  • Visual Studio
  • (Practice) How to start a new ASP.NET Web Application project

1.2 Client-Server Model

Client-Server Model distributes processing btw:

  • server: provider of resources/services
    • e.g. of Web server app: Internet Information Service (IIS), Apache HTTP Server, Oracle iPlanet Web Server
  • client: users of resources
    • e.g. of Web client app: Microsoft Internet Explorer, Google Chrome.

Web Page: Static or Dynamic

  • Static web page: do not change for all requests.
    • Before HTML5, .html/.htm files are static web pages.
  • Dynamic web page: can change its look everytime requested.
    • some file extension related to dynamic web page e.g. .php (hypertext preprocessor), .jsp (java server page).
    • Dynamic web pages are processed by both a web server and an app server, or db server

Processing cycle of a static Web page Processing cycle of a static Web page:

  1. Client requests a Web page from a Web server via HTTP request. content of request:
    1. Web page
    2. IP of server & client
  2. After server received HTTP request, it
    1. locates desired web page file.
    2. Then attach HTML file to HTTP response.
    3. send back to client

Processing cycle of a dynamic Web page Processing cycle of a dynamic Web page:

  1. Client requests a Web page from a server via an HTTP request. content of request:
    1. name of dynamci Web page (e.g. Display_Products.aspx)
    2. state of Web page controls (e.g. name in text box)
  2. After server received HTTP request
    1. Check file exentention is .aspx, then pass processing control to the business logic of the server app (i.e. ASP.NET & C# code)
    2. If business logic requies service from db (e.g. reading, inserting), the app server pass processing control and related args to db server.
    3. After db server finish execution, it pass control back to app server
    4. App server pass data/response back to web server
    5. Web server formats HTML based on app server's work
    6. Web server attach HTML to HTTP response
    7. Web server sends response back to client

This is a full backend service processing cycle

1.3 .NET Framework

  • .NET Framewok = Windows-based software dev and execution framework
  • It consists of
    • Framework Class Library (FCL): a large library of classes to create Windows desktop app, or Web app using VB, VC++, VC#, etc.
    • Common Language Runtime (CLR): environment where all .NET app executed. (Execution logic shown below)

Organization of the .NET Framework

1.4 OOP

A class can contain properties & methods and can handle events.

  • event = end-user actions or other things that occur in time.
  • properties, methods, events are all members of the class

1.4.1 Class and Objects

2 types of classes in .NET Framework:

  • non-static class: contain non-static members that we can use, ONLY after we initialize an object from it.
  • static class: contain static members that can be directly utilized w/o initialization

Class diagram (e.g. shown below, used to describe class in the book) include:

  • name of class
  • namespace of the class resides in: contain classes that provide specific functionality or specialized tpe
  • selected properties, methods, events
  • event handler methods are omitted in diagram in this book
    • event handler methods = handler methods that raised by event; begin with "On", end with event name.

1.4.2 Properties

Properties:

  • = data of class
  • can be read from (via get method) and written to (via set method)

1.4.3 Methods

Omitted

1.4.4 Events

Events are things that happened

  • Raised by user action or sth in future.
  • When event is raised, methods are invoked to handle it.
    • e.g. .NET Page class raises a Load event every time client reload web page.
  • Events can be static or non-static for different class.

1.4.5 Encapsulation

Encapsulation refers to two notions (concepts):

  • A class's properties & methods are bundle together and treated as a single unit
  • A class's properties & methods cannot be directly accessed by code outside of the class.

Access restriction (enfored when declaring):

  • private: only accessed by code within the obj itself
  • protected: accessed by code within the obj itself and child class objs.
  • public: accessed by code in other class.