Wednesday, 3 October 2012

Differences between Cache,Session and ViewState in Asp.Net

  • memory.
  • allow you to store difficult and complex constructed data which can be reused.
  • is available to be accessed from global/application level where one reference to memory is updated. Each request will use the same cache for different users.
  • a period of time that is shared between the web application and the user.
  • Each user that is using the web application has their own session.
  • The Session variables will be cleared by the application which can clear it, as well as through the timeout property in the web config file.
  • Session variables will use different session variables for each different user.
  • hidden data that is kept by ASP.NET pages.
  • track the changes to a web site during post backs.
  • All server controls contain a view state. [EnableViewState property - enable/disable if the control properties will be held in hidden fields.]
  • Having a large ViewState will cause a page to download slowly from the user’s side.- When a user clicks on a button and a post back occurs, all the view state information has to be posted back to the server which causes a slower request.
  • ViewState should be limited to what is needed.- Data can also be written into the ViewState. – The ViewState only persists for the life cycle of the page.
  • If the page redirects to another page, or even to itself, the ViewState will be reset.
  • ViewState should be used to hold small amounts of data, which will be only used on the current page

No comments:

Post a Comment

Total Pageviews