i

ASP.Net A Complete Guide

State Management and Web Applications

State management stores the information of any user from he logged in to the application till the end of the user session. State management helps to maintain the state of control and object in a browser because ASP.NET web applications are stateless.

Whenever a user requests some information to server using the Http or Https protocol, then the browser receives some input as a response. What happens when the user closes that browser and again tries to open the same web page, then the browser won't remember the was the requesting user did last time and what expected the response he should receive. So from this scenario, we called browser as stateless

There are 2-types of state management methodology:

1. Client-Side State Management: In this technique, information stored on the client-side (browser). Below are the client-side techniques to save state:

ViewState: View state comes in pictures when the user wants to preserve data temporarily after a Postback event. In such a scenario, ViewState has used the most used technique. It stores data in the HTML using hidden fields at the client-side. View state is enabled by default using a property "EnableviewState" set to true.

Some important fact:

  • It holds data temporarily.

  • It can store any kind of data regardless of considering the data types.

  • It is also called as page-level state management

QueryString:  QueryString used in such cases where we want to move information from one page to another page.

Some important fact:

  • It holds data temporarily

  • Values switch info from one to another page

  • Increase performance

Hidden Fields: It means field and their value is there, but it is not visible to the end-user. It is used to store a small amount of data. It can be used when there is a need to hold a small amount of information or single, and that is frequently changing, and then this technique is the most preferred technique.