State management Summary

The summary of different state management techniques and their recommended use:

S. No. State Management Technique Advantages Disadvantages Recommended Use Lifetime/Scope
Client Side State Management
1. View State ASP.Net in built state management technique.
Can be used to store small amount of information in encrypted form at client side.
It is sent back and forth in each page request and post back so their may be performance hit if large amount of data is stored in that.
State is retained only when post request is made to page.
When small amount of data needs to be stored on the page which is needed when post request is made to a page. Per Page
2. Query Strings It can be used to pass small amount of data b/w pages. Data passed in the url so security may be issue and it should not be used to pass any sensitive data. It can be used to pass any general information b/ pages of application. Per Page
3. Hidden Fields It can be very useful when additional information needs to sent to client side for validations. All the information is stored at client side and anyone can view it using source of the web page. It can be used very carefully as all the information is at client side. Generally it is used to pass data which can be used to validate user entries on the page. Or it can b used to contain values specific to user. Per Page
4. Cookies State is stored at client side.
It can be shared across multiple sessions in case of permanent cookie.
Depends on client browser setting.
It can not be used for large amount of data as it is sent back and forth in each page request.
When small amount of data less than 4 KB needs to stored at client side. Generally used for authentication in ASP.Net. It can be used in case site retains user preferences. Per Client
Server Side State Management
5. Session State It can be shared with different machine and different processors.
It can use persistent medium like SQL server or different processes.
Storing state in persistent medium can be hard to maintain.
Uses Cookies or URL to manage state.
Generally used in ASP.Net application to store state specific information this can be shared across page for a single client. Per Client
6. Application State It can be shared across all the clients. It can not be shared b/w machines and processors.
Its use should be limited as it can reduce scalability of the application.
When information needs to shared with all clients. I.e. number of active users to application. All Clients/Application Lifetime