Upload
shrijan-tiwari
View
26
Download
0
Embed Size (px)
Citation preview
In this session we will learn about
ASP.NET state management overview
Client –side state managementServer-side state management
state management overview
HTTP ( Hyper Text Transfer Protocol) is a stateless
protocol. When the client disconnects from the server,
the ASP. Net engine discards the page objects. This way
each web application can scale up to serve numerous
requests simultaneously without running out of server
memory.
However, there need to be some technique to store the
information between requests and to retrieve it when
required. This information i.e., the current value of all
the controls and variables for the current user in the
current session is called the State.
ASP.NET State Management
In a Web programming, this would typically mean
that all information associated with the page and the
controls on the page would be lost with each round
trip. To overcome this inherent limitation of
traditional Web programming,
Continue…….
ASP.NET includes several options that help you
preserve data on both a per-page basis and an
application-wide basis.
We can secure data at both side: Serer side and
Client side using
Client Side State Management
Server side State Management
Storing page information using client-side
options doesn't use server resources.
These options typically have minimal security
but fast server performance because the demand on
server resources is modest.
Client-Based State Management
Continue…….
The following are the client-side state management options that ASP.NET supports:
View state Hidden fields Cookies Query strings
View State
View State
The View State property provides a dictionary object
for retaining values between multiple requests for
the same page.
This is the default method that the page uses to
preserve page and control property values between
round trips.
Continue…….
When the page is processed, the current state of the
page and controls is hashed into a string and saved in
the page as a hidden field.
When the page is posted back to the server, the page
parses the view-state string at page initialization and
restores property information in the page.
Hidden Fields
Hidden Fields
ASP.NET allows you to store information in a Hidden
Field control, which renders as a standard HTML
hidden field.
When a page is submitted to the server, the content
of a hidden field is sent in the HTTP form collection
along with the values of other controls.
Query Strings
Query Strings
A query string is information that is appended to the
end of a page URL. In order for query string values to
be available during page processing, you must
submit the page using an HTTP GET command.
Cookies
Cookies
A cookie is a small amount of data that is
stored either in a text file on the client file system or
in-memory in the client browser session.
Continue…….
It contains site-specific information that the server
sends to the client along with page output.
Cookies can be temporary (with specific expiration
times and dates) or persistent.
Advantages of using Client-Side state management
No server resources are required Simple implementation Enhanced security features Reliability Data persistence
Disadvantages of using cookies are:
Performance considerations
Size limitations: Most browsers place a 4096-byte
limit on the size of a cookie, although support for
8192-byte cookies is becoming more common in
newer browser and client-device versions.
User-configured refusal
Potential security risks