0% found this document useful (0 votes)
11 views13 pages

Lecture 4

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views13 pages

Lecture 4

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

ASP.

NET Course
by T. Ala’a Khalid

1
Lecture 4
ViewState, Session State and

Application State

2
Lecture Objectives
 Levels of ASP.Net web application events
 Sending data from one web form to another
 Difference between ViewState, Session
State and Application State

3
Levels of ASP.Net web application events

 In a web application, events can occur at 3 levels


 At the Application Level (Example: Application_Start)
 At the Page Level (Example: Page_Load)
 At the Control Level (Example: Button_Click)

4
Sending data from one web form to another

 ASP.Net provides some techniques to send data from


one web form to another
 Query Strings
 Cookies
 Session State
 Application State

5
Difference between ViewState, Session
State and Application State
 ViewState
 ViewState variables are used to preserve data across
page postbacks
 By default, ViewState of one web form is not available
in another web form (available only in that web form)
 ViewState is stored on the page in a hidden field
called_ViewState. Because of this, the ViewState, will
be lost, if you navigate away from the page, or if the
browser is closed
 ViewState is used by all ASP.Net controls to retain
their state across postbacks

6
Difference between ViewState, Session
State and Application State
 ViewState

7
Difference between ViewState, Session
State and Application State
 Session State
 What is a Session in a web application?
 Session is a unique instance of the browser
 A single user can have multiple sessions
 by visiting the web application with multiple instances of
the browser running with a different session-id

 Session State variables are available across all pages,


but only for a given single session
 Session State variables are like Single-User global data
 Only the current session has access to its Session
State

8
Difference between ViewState, Session
State and Application State
 Session State
 Session State variables are stored on the web server
 Session State variables are cleared, when the user
session times out. The default is 20 minutes. This is
configurable in web.config

9
Difference between ViewState, Session
State and Application State
 Session State

10
Difference between ViewState, Session
State and Application State
 Application State
 Application State variables are available across all pages
and across all sessions
 Application State variables are like Multi-User global data
 All sessions can read and write Application State
variables
 Application State variables are stored on the web server
 Application State variables are cleared, when the process
hosting the application is restarted

11
Difference between ViewState, Session
State and Application State
 Application State

12
Levels of a web application events

H.W
 In a web application, events can occur at 3 levels
 List the events of each level and their functionality

13

You might also like