Server Side state management is another technique of maintaining state of asp.net webpages. Another alternative is client side state management.
Server Side State Management has 2 options
-
Session
- One of the most strongest technique to store information
- Generally used for storing user information such as username or user identity
- It does with maintaining a session id and sends it with each request and response to the same user.
Syntax :
Session[“variablename”] = Convert.ToInt32(Session[“variable”]) + 1;//Set Value to The Session Label2.Text = Session[“variablename”].ToString(); //Get Value from the Sesion
-
Application
- It is another type of server side state management technique.
- The data stored in the application is common for all the users for the application.
- It is also referred as application level state management.
- It is recommended to store small amount of data.
Syntax:
Application[“variablename”] = Convert.ToInt32(Application[“variablename”]) + 1; //Set Value to The Application Object Label1.Text = Application[“variablename”].ToString(); //Get Value from the Application Object