Interview

Difference between ViewState, Session State and Application State in asp.net

ViewState:

1. ViewState of a webform is available only with in that webform

2. ViewState is stored on the page in a hidden field called _ViewState. Because of this, the ViewState, will be lost, if you navigate awaya from the page, or if the broswer is closed.

3. ViewState is used by all asp.net controls to retain their state across postback

Session State:

1. Session state variables are available across all pages, but only for a given single session. Session variables are like single-user global data.

2. Session state variables are stored on the web server.

3. SessionState variables are cleared, when the user session times out. The default is 20 minutes. This is configurable in web.config

Application State:

1. Application State variables are available across all pages and across all sessions. Application State variables are like multi-user global data.

2. Application State variables are stored on the web server.

3. Application State variables are cleared, when the process hosting the application is restarted.

About the author

shohal

Leave a Comment