Basic Structural Concepts of .NET

13
Christopher M. Pascucci Basic Structural Concepts of .NET Browser – Server Interaction

description

Basic Structural Concepts of .NET. Browser – Server Interaction. Christopher M. Pascucci. Introduction. Web applications are a type of client/server application, which means that the functions of the applications are split between the client computer and server computer. - PowerPoint PPT Presentation

Transcript of Basic Structural Concepts of .NET

Page 1: Basic Structural Concepts of .NET

Christopher M. Pascucci

Basic Structural Concepts of .NET

Basic Structural Concepts of .NET

Browser – Server InteractionBrowser – Server Interaction

Page 2: Basic Structural Concepts of .NET

Introduction Web applications are a type of client/server application, which

means that the functions of the applications are split between the client computer and server computer.

Client and servers are connected together via the Internet or other network and they communication using HTTP (Hypertext Transfer Protocol)

Web server stores the web applications that are accessed by the clients. They can be configured to process ASPX, JSPX, PHP, etc… Example web servers: Microsoft IIS & Apache

Most web applications use data stored in a database so it needs to implement a connection to a DBMS like SQLserver or Oracle.

Internet

Web browser Web serverDatabase management system

Client computer Server computer

Page 3: Basic Structural Concepts of .NET

Processing Static Web Pages Static web pages are simple HTML pages that are stored on a web

server. These pages don’t change in response to user input and the content is always the same.

A web browser requests a page from a web server by sending the server an HTTP request. This request is initiated by typing in a URL, clicking a link, or begin

redirected. Includes the name of the HTML file being requested, the IP address of

both the web browser and web server, etc… A web server replies to a request with an HTTP response.

The response includes the HTML doc being requested.

Client Server

Browser Web server HTML file

HTTP request

HTTP response

Page 4: Basic Structural Concepts of .NET

Processing Dynamic Web Pages Dynamic web pages are HTML pages that can change in some way each time the

page is displayed. They are a web form with controls that allow the user to interact with the application.

Instead of being stored in the form of HTML, they are generated dynamically by the web application.

1. A web server receives a request for a dynamic page, it looks up the file extension of the requested file in a list to find out which application server should process this request. If the extension is ASPX, the request is passed on to ASP.NET for processing. If the extension is JSPX, the request is passed on to Tomcat for processing.

2. The application server receives the request and it runs the web form. The web form then generates an HTML document and returns it to the web server.

3. The web server then sends the

HTML document back to the

browser.

Client Server

BrowserWeb server

(IIS)

Applicationserver

(ASP.NET)

HTTP request

HTTP response

Webapplication

forms(.aspx)

Page 5: Basic Structural Concepts of .NET

Dynamic Pages After a dynamic page is displayed on the browser, the user can

interact with it using its controls. Some of the controls let the user start an HTTP request that post the page back

to the server, which is called a postback. The page is then processed over again using the data the user entered. The entire process that starts with a browser requesting a page and ends with

server returning the page is called a roundtrip.

There are two ways to a page can cause a postback to the server. By using a submit button. <input type=”submit” name=“btnSub”>

Through script. <script lang=“vbscript”>

Sub checkForm()formName.submit()

End Sub</script>

Page 6: Basic Structural Concepts of .NET

ASPX Browser – Server Interaction

Page 7: Basic Structural Concepts of .NET

Christopher M. Pascucci

Basic Structural Concepts of .NET

Basic Structural Concepts of .NET

Managing State & ScopeManaging State & Scope

Page 8: Basic Structural Concepts of .NET

What is State State refers to data maintained by an application for a single user. An application must maintain a separate state for each user. HTTP is a stateless protocol, which means it doesn’t maintain state

between roundtrips. Since HTTP is stateless the web applications must handle this.

ServerFirst HTTP request:The browser requests apage.

Client

Web server

First HTTP response:The server returns therequested page and theapplication ends.

Next HTTP request:The browser requests anotherpage. The server has no wayto associate the browser withits previous request.

Web server

Web serverBrowser

Browser

Browser

Page 9: Basic Structural Concepts of .NET

How ASP.NET Maintains State ViewState (Page) Request Application Session Cookies Cache

Page 10: Basic Structural Concepts of .NET

How ASP.NET Maintains State ViewState (Page)

Maintains the values of form control properties. ViewState is implemented by default. When a webform (aspx) is loaded, it can re-post to itself by means of a form

submit. A special state Boolean variable named IsPostBack is set to False when the

page is initially loaded, and to True after its first postback. Page state is maintained across postbacks to a single page by a single user. Page state is sometimes called ViewState, because there is a ViewState object

that contains property values for controls in the webform as well as the user created attribute/value collection; however, only simple data types and serializable objects can be stored in the ViewState object.

ViewState is maintained across postbacks.• It stores the information (encrypted) in a hidden field in the form.• <input type="hidden" name="__VIEWSTATE"

value="dDwtMzQzNDc3MjYyO3Q8O2w8aTwyPjs+O2w8dDw7bDxpPDY+O2k8Nz47PjtsPHQ8cDxwPGw8VGV4dDs+O2w8SEVMTE8gTVIuIEEgQTs+Pjs+Ozs+O3Q8cDxwPGw8VGV4dDs+O2w8TWVzc2FnZTogYTs+Pjs+Ozs+Oz4+Oz4+O2w8b3B0TXI7b3B0TXM7b3B0TXM7b3B0RHI7b3B0RHI7Y2hrVXBwZXI7Pj4YjhxhXxf0Ix5rYidfnJsm+x6wrw==" />

Page 11: Basic Structural Concepts of .NET

How ASP.NET Maintains State Request

A Request object is created whenever a URL request is made from the browser to a web server.

Request state is maintained during the life of a single request object. The program can access data from web form controls on the server-side by

simply using Request(“FormControlName”) in the code.

Application Application state is shared among all users (sessions) of an application. It can be used to maintain values that apply to all users and you can add your

own data/values to the application state object. The Application is all pages contained in a given web site. The application starts

when the first user sends a URL to the web server on which the web is located. It ends when the last client (user) of the web ends its session or when the application is stopped/restarted.

Page 12: Basic Structural Concepts of .NET

How ASP.NET Maintains State Session

Session state is unique to each user of an application but maintained throughout their use of the application. 

A Session is started when a user sends a URL to activate a given web site or Application.

The session can end in one of 3 ways:

1. If there is no request sent for a time called the Session Inactive Time. There is a default value set within the web server for this time, but it can be overridden by the session.Timeout property for a particular session object.

2. By the program using the session.Abandon method

3. If the client is terminated by closing the browser window, but Session Inactive Time will still have to elapse.

Page 13: Basic Structural Concepts of .NET

How ASP.NET Maintains State Cookies

Cookie state is maintained in the client browser and can persist across page, session and application state.

It can even persist after the application terminates, for any predetermined time period. Its lifetime can be programmatically controlled.

Cache Cache state has application scope but variable lifetime determined by the

following events:• Specific files or database tables being updated• Another Cache attribute changes value• Time expiration