Page:
1_WebApplicationDevelopment
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.
- Before HTML5,
- 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
- some file extension related to dynamic web page e.g.
Processing cycle of a static Web page:
- Client requests a Web page from a Web server via HTTP request. content of request:
- Web page
- IP of server & client
- After server received HTTP request, it
- locates desired web page file.
- Then attach HTML file to HTTP response.
- send back to client
Processing cycle of a dynamic Web page:
- Client requests a Web page from a server via an HTTP request. content of request:
- name of dynamci Web page (e.g.
Display_Products.aspx
) - state of Web page controls (e.g. name in text box)
- name of dynamci Web page (e.g.
- After server received HTTP request
- Check file exentention is
.aspx
, then pass processing control to the business logic of the server app (i.e. ASP.NET & C# code) - If business logic requies service from db (e.g. reading, inserting), the app server pass processing control and related args to db server.
- After db server finish execution, it pass control back to app server
- App server pass data/response back to web server
- Web server formats HTML based on app server's work
- Web server attach HTML to HTTP response
- Web server sends response back to client
- Check file exentention is
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)
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 (viaset
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.