State Management Technique In .NET : A short Trip
This article gives you a short idea about a State Management Technique in .NET. You will know What is State Management? Why we use State Management? Types of State Management etc.
State Management Technique in .NET: A short Trip
What is State Management ?
It is the Technique by which we can maintain the sate and Information of the page over multiple request. Why we use State Management?
Page information is not persist beyond each life cycle of page because pages are destroyed and recreated each time of round trip to server
We can call this round trip as POSTBACK
ASP.NET provide a verious ways of maintaining state of pageWhat are the types of State Management?
There exist two types of State Management
1. Client Side State Management - store values on Client
2. Server Side State Management - store values on ServerWhich is good to use State Management?
This is the critical question, it is typically depend on following things
1. How long do you want to store the information
2. How information do you need to store
3. What are your browser capabilitiesClient Side State Management?
Client side State Management handle with the following ways
- View state
- Control state
- Hidden fields
- Cookies
- Query strings
basically when we want a minimal security and fast performance then client side State Management is good optionView State
view state is use to store our own page-specific values across round trips. Every ASP.NET page has a property of View state to store values between round trips
We can Turnoff viewstate for specific page. it has some bold features like
- server resources not required.
- ease in implementation.
- Fast in Performance. When to use State Management:
It is used when we need to store small amounts of information for a page
Control State
This is not much popular way to persist state. it persist custom control data between multiple postbacks. Like View state we can not
SWITCH OFF control state. It is good way to managing state of control
Let's see some bold features
- a more reliable method for managing the state of controls
- Versatile
when to use : It is used when we need to store small amounts of for a control between round trips
Hidden Fields
Hidden fields maintain the state between postabacks. we can store user specific data in hidden fields. we can used to when security is not an issue
It has some disAdvantages like it has storage limitation, it will slow down perfomance if we trying to put large value in it, Potential security risks.
some of the bold features are
- widely used
- Support to almost all browsers.
- simple architecture.
when to use : It is used when we need to store small amounts of frequently changed data
Cookies
Basically cookies are small files that are stored on client machine. We can create cookies. There are two types of cookies exist
1. Persistent cookie
2. Non Persistent cookie
where Persistent cookie has expiration period
when to use : It is used when we need to store small amounts of data where security is not aspect
Query Strings
A Querystring is the data that is appended to the URL with the '?' sign, however it is simple but limited way of transfering data
Query Strings has advantages and drawbacks too
Query Strings good points are as follows
- easy to build
- support from all Browsers
Query Strings Drawbacks
- URL is visible to user leads to risk of data loss
- URL length limitation
when to use : It is used when we need to Transfer small amount of data like username
--------------------------------------------------
Server Side State Management ?
In Server Side State Management information stored on server so it has a higher security than client side.
Server side State Management handle with the following ways
- Application state
- Session state
- Profile properties
Application state
It is good way to accessible information through all application which is managed by server. We can store our application level values in this veriables.
It get's initialised in GLOBAL.ASAX. This is common for all users.
some of the bold features are as follows
- Easy to implement
- Lock / Unlocking facility avaliable
- Information accessible through all pages
- Information accessible to all users
when to use : It is used when we need to store global information that is not chnaged frequently but used by many users
Session state
This is a good way to store user specific information, It allows you to store and retrive values for a specific user between
multiple postbacks. You do not have to declear session veriable explicitly.
Some Advantages are as follows
- support to large dataTypes
- User wise information can be maintain
This is short lesson about the CSS.
when to use : It is used when we need to store short-lived information that is specific to an individual user
Profile properties
It is not very well known way to maintaining data accross postbacks
This allow you to store user specific data, it is same like session but Profile data not get lost even after session expires
Profile properties are stored in persistent format
when to use : It is used when we need to store user-specific information that needs to be persisted after the user session is expired
Thanks
There are many ways to transfer data from one page to another.Many of new Web application developers May get confused about it. This is short attempt to make the confusion clear.
Suggestion are most welcome
Thanks
koolprasad2003
yes this is a good article for the user of asp .net
use this article to read about state view in asp .net
regards
Niraj Kumar Mundel