Pages

Wednesday, December 12, 2012

State Management in ASP.NET


One of the frequently asked question in Newsgroups or Usergroups is regarding "State Management in ASP.NET". So here  i will give the short decription about various option for State management in ASP.NET and will give the links to various article which explains detaily about various options for state management in ASP.NET.

Session

     Is used for storing user specific data which needs to be persistant between requests for the same page/different pages in a request.

Httpcontext.Cache

     Is Used to store Application level STATIC data (which doesn't change frequently.)

Application 

     This is kind of kept for backward compatibility. I prefer using Cache to store Application level data since you have more flexibility with how you want to manage the cache. You can even set expiration for Cache object which is not possible using application.

ViewState 

       You can use this to store data between multiple requests to the same page.

HttpContext.Current.Items 

       You may use this to store data to be available per page level OR when you want to transfer data between pages using server.transfer (but this is not the suggested way to transfer data between pages.) the suggested way is to use page level public properties and access them from the destination page.
We have few other options like using cookies, using querystring and stroing in database also. Since there are lots of options availble you need to analyze use proper one which suits your application requirements

Related Links

No comments:

Post a Comment