Difference Between Viewstate and Sessions

Results 1 to 4 of 4

Thread: Difference Between Viewstate and Sessions

  1. #1
    Join Date
    Dec 1969

    Default Difference Between Viewstate and Sessions

    Can someone tell me the difference between the 2 !!!!!!!<BR><BR>I feel both do the same job !!! which is advantageous ?<BR><BR>Please clarify !

  2. #2
    Join Date
    Dec 1969

    Default apples and oranges

    ViewState adds the ability to remember which selection an end made to a control set to runat=server without writing additional code.<BR>The session object is an object that allow a developer to persist data from page view to page view on a user by user basis.<BR>

  3. #3

    Default RE: Difference Between Viewstate and Sessions

    Where they are stored.<BR>Session data is stored on the server, in memory.<BR>ViewState data is stored in a hidden input the is passed with each PostBack.<BR><BR>More like "Chicken or Fish"

  4. #4
    Join Date
    Dec 1969

    Default RE: Tomatos & Radishes?

    ViewState is page specific (ie items saved to the viewstate of a page are only available to that page and are lost when you leave the page).<BR><BR>Items placed in session are specific to that session, but are available to all pages accessed in that session. This is an important difference if you want data available to multiple pages in your application.<BR><BR>Also remember that items in viewstate are actually stored in a hidden text field on your page so are posted back to the server with each postback. If you put something large (like a dataset) in viewstate, you are dragging it back and forth between the server and browser with each post. Session objects, on the other hand, sit in memory on the server.<BR><BR>The other place to preserve data is in Cache so you how have apples, oranges and bananas.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts