Home > DeveloperSection > Articles > State management in ASP.Net

State management in ASP.Net

1 Comment(s)
 1480  View(s)
Rate this:

State management in ASP.Net

In this article, I’m explaining about State management  in ASP.Net

 State management is the process by which you maintain state and page information over multiple requests for the same or different page.

Types of State Management

1.     Client - Side State Management

2.     Server – Side State Management

 Client Side State Management

This  Stores information  on the client’s computer.

Types of Client Side State Management

1.View State

2.Hidden Field


4.Query String

 Hidden Field

Hidden fields are html input  control with  a type  of hidden <input type=”hidden”> .  They are used to store data in the html without presenting the data in the browser. The data of hidden field  is available when  the form is processed or when  using javascript. The viewstate use hidden field to save its data. You can use the View Source operation (if enabled) to scan the web page’s source and to look for hidden fields.

View State

View state is used to maintain the state of  controls  during  Page Postback  if we save any control values  or anything in viewstate we can access those value throughout the page.     

 Query String

Query string state is stored in the URL that is sent to the browser.
Unlike ViewState and hidden fields, the user can see the values without using
special operations like View Source. The parameters are passed in the URL
separated by symbol.


Cookies store a value in the user’s browser that the browser sends with every page request to the same server. Cookie Default expires value is 30 minutes.

Types of cookies

  1.Persistent cookies

 2. Non persistent cookies

Persistent Cookies

These can be  called permanent cookies,  which  are stored in client hard disk. They stay on your hard disk and  can be accessed by  web server until they are  deleted or have expired.


public void SetPersistentCookies(string name, string value){
 HttpCookie cookie = new HttpCookie(name);
 cookie.Value = value;
 cookie.Expires = Convert.ToDateTime(“12/12/2008″);

Non persistent cookies

Cookies  are saved  only  while your  web browser is running.  They can be  used  by a web server only until you close  your browser. They are not saved in client hard disk.


public void SetNonPersistentCookies(string name, string value){
 HttpCookie cookie = new HttpCookie(name);
 cookie.Value = value;

 Server – Side State Management

      1.Application State

2. Session State            

3. Profile

4. Caching


Caching is not per-user based. Caching data is stored at the application level and shared by all the users. Caching only one memory will be allocated on the server and if one user modifies the data of the cache for all, the user data will be modified.

3 types of caching in ASP.NET:
Output Caching
Fragmentation Caching
Data Caching

 Application State

 Application level state Management is used to maintain the state of all the users accessing  the webforms present within the website.

If  any data is stored on the  application object then that information will be  shared upon  all  the users accessing the  webserver.

Whenever the server has been restarted or stopped then the information maintained by  the application object  will be lost.


 Profile allows  are  used to store user-specific  data in the application. The profile  properties are maintained in the database and will  be retrieved and set in the database just by setting  the profile properties in the code.To use Profile we need to set the profile element in the web.config.

add name="FirstName" />


Session objects are stored on the  server side. It can be used to store any type of data in the memory. Session Default expires value is 20 minutes.

 Types of session mode

1. Inproc

2. Outproc

3 Off


Session are stored in server memory called  as in-process.

Outproc Mode:

Types of outproc Mode

1.   .State Server

2.     SQL server

3.     Custom


StateServer mode, which stores session state  in a separate process  called the ASP.Net .


SQLServer mode stores session state in a SQL Server database.


Custom mode, which enables you to specify a custom storage provider.

Nice Article

By Kamlakar Singh on   one year ago
very helpful article for me
please continue writting

Don't want to miss updates? Please click the below button!

Follow MindStick