SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Apr 2009
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Difference Between Viewstate and Session

    Hi there

    I want to know about difference between viewstate and session, can anyone highlight.

    Thanks
    WebS

  2. #2
    SitePoint Enthusiast MetalHippy's Avatar
    Join Date
    Nov 2008
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    quick answer..

    The ViewState is maintained at page level and nainly keeps the values of controls of particular page in the client (browser) when post back operation done, although it can also be used to store other data. When user requests another page the data from the previous page is no longer available.

    The Session keeps the data of particular user in the server, this data is available to all pages until user close the browser or session time completes.

    Hope this helps

    Mike
    One Life - Live It

  3. #3
    SitePoint Member
    Join Date
    May 2009
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In ViewState the the object are serialized and stored in hidden fields within the page. After the post back the server updates this field with the new set of values for which any older value is destroyed. In SessionState a part of the memory of the server for a particular client is used to store client specific data. This data are available till the session is active after the session is abandoned these data are deleted.

  4. #4
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,629
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Also remember that Sessions are user-static. Meaning that, if a user has two pages open and they both are accessing the same variable stored in a session, you can easily end up with race conditions.


Bookmarks

Posting Permissions

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