Session and View State variables

Discussion in 'ASP .Net' started by John Smith Jr., Dec 22, 2003.

  1. Could someone enlighten me what the difference between viewstate[" and
    session[" variables in terms of use, performance, and rule of thumb, from
    what I understand viewstate has overhead to it, and is passed with the page
    encrypted where session is stored locally in the aspnet_wp.exe process.

    Also, how do class member variables fit in the mix?
     
    John Smith Jr., Dec 22, 2003
    #1
    1. Advertising

  2. Viewstate variables are stored in the HTML of your page. They are encoded
    so they are not easily readable, but they are not encrypted. This is
    generally the best scope to use when you have a variable that is valid for a
    particular page and you want to store the value between postbacks. Once the
    user navigates to another page the value is lost.

    Session variables are stored on the server (in RAM by default) and are
    persisted between all pages.

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://Steve.Orr.net
    Hire top-notch developers at http://www.able-consulting.com




    "John Smith Jr." <> wrote in message
    news:...
    > Could someone enlighten me what the difference between viewstate[" and
    > session[" variables in terms of use, performance, and rule of thumb, from
    > what I understand viewstate has overhead to it, and is passed with the

    page
    > encrypted where session is stored locally in the aspnet_wp.exe process.
    >
    > Also, how do class member variables fit in the mix?
    >
    >
     
    Steve C. Orr [MVP, MCSD], Dec 22, 2003
    #2
    1. Advertising

  3. Thank you, very clear answer.

    How about class variables to the page, I understand they are only available
    for that page, and not the application, but are those sent with postback or
    they handled on the server in ram only?


    "Steve C. Orr [MVP, MCSD]" <> wrote in message
    news:%...
    > Viewstate variables are stored in the HTML of your page. They are encoded
    > so they are not easily readable, but they are not encrypted. This is
    > generally the best scope to use when you have a variable that is valid for

    a
    > particular page and you want to store the value between postbacks. Once

    the
    > user navigates to another page the value is lost.
    >
    > Session variables are stored on the server (in RAM by default) and are
    > persisted between all pages.
    >
    > --
    > I hope this helps,
    > Steve C. Orr, MCSD, MVP
    > http://Steve.Orr.net
    > Hire top-notch developers at http://www.able-consulting.com
    >
    >
    >
    >
    > "John Smith Jr." <> wrote in message
    > news:...
    > > Could someone enlighten me what the difference between viewstate[" and
    > > session[" variables in terms of use, performance, and rule of thumb,

    from
    > > what I understand viewstate has overhead to it, and is passed with the

    > page
    > > encrypted where session is stored locally in the aspnet_wp.exe process.
    > >
    > > Also, how do class member variables fit in the mix?
    > >
    > >

    >
    >
     
    John Smith Jr., Dec 22, 2003
    #3
  4. John Smith Jr.

    Hermit Dave Guest

    if the member variable is a web control then the state is passed along in
    the ViewState
    from which it is retrieved and restored on postback.
    Ordinary variables are not persisted @(Since the instance of the page class
    running is discarded once processing is finished)

    If you want to persist you own set of variables... either add and retrieve
    them from view state or the session

    Hope this help

    HD

    "John Smith Jr." <> wrote in message
    news:...
    > Thank you, very clear answer.
    >
    > How about class variables to the page, I understand they are only

    available
    > for that page, and not the application, but are those sent with postback

    or
    > they handled on the server in ram only?
    >
    >
    > "Steve C. Orr [MVP, MCSD]" <> wrote in message
    > news:%...
    > > Viewstate variables are stored in the HTML of your page. They are

    encoded
    > > so they are not easily readable, but they are not encrypted. This is
    > > generally the best scope to use when you have a variable that is valid

    for
    > a
    > > particular page and you want to store the value between postbacks. Once

    > the
    > > user navigates to another page the value is lost.
    > >
    > > Session variables are stored on the server (in RAM by default) and are
    > > persisted between all pages.
    > >
    > > --
    > > I hope this helps,
    > > Steve C. Orr, MCSD, MVP
    > > http://Steve.Orr.net
    > > Hire top-notch developers at http://www.able-consulting.com
    > >
    > >
    > >
    > >
    > > "John Smith Jr." <> wrote in message
    > > news:...
    > > > Could someone enlighten me what the difference between viewstate[" and
    > > > session[" variables in terms of use, performance, and rule of thumb,

    > from
    > > > what I understand viewstate has overhead to it, and is passed with the

    > > page
    > > > encrypted where session is stored locally in the aspnet_wp.exe

    process.
    > > >
    > > > Also, how do class member variables fit in the mix?
    > > >
    > > >

    > >
    > >

    >
    >
     
    Hermit Dave, Dec 22, 2003
    #4
  5. Ahh, thank you much.


    "Hermit Dave" <> wrote in message
    news:...
    > if the member variable is a web control then the state is passed along in
    > the ViewState
    > from which it is retrieved and restored on postback.
    > Ordinary variables are not persisted @(Since the instance of the page

    class
    > running is discarded once processing is finished)
    >
    > If you want to persist you own set of variables... either add and retrieve
    > them from view state or the session
    >
    > Hope this help
    >
    > HD
    >
    > "John Smith Jr." <> wrote in message
    > news:...
    > > Thank you, very clear answer.
    > >
    > > How about class variables to the page, I understand they are only

    > available
    > > for that page, and not the application, but are those sent with postback

    > or
    > > they handled on the server in ram only?
    > >
    > >
    > > "Steve C. Orr [MVP, MCSD]" <> wrote in message
    > > news:%...
    > > > Viewstate variables are stored in the HTML of your page. They are

    > encoded
    > > > so they are not easily readable, but they are not encrypted. This is
    > > > generally the best scope to use when you have a variable that is valid

    > for
    > > a
    > > > particular page and you want to store the value between postbacks.

    Once
    > > the
    > > > user navigates to another page the value is lost.
    > > >
    > > > Session variables are stored on the server (in RAM by default) and are
    > > > persisted between all pages.
    > > >
    > > > --
    > > > I hope this helps,
    > > > Steve C. Orr, MCSD, MVP
    > > > http://Steve.Orr.net
    > > > Hire top-notch developers at http://www.able-consulting.com
    > > >
    > > >
    > > >
    > > >
    > > > "John Smith Jr." <> wrote in message
    > > > news:...
    > > > > Could someone enlighten me what the difference between viewstate["

    and
    > > > > session[" variables in terms of use, performance, and rule of thumb,


    > > from
    > > > > what I understand viewstate has overhead to it, and is passed with

    the
    > > > page
    > > > > encrypted where session is stored locally in the aspnet_wp.exe

    > process.
    > > > >
    > > > > Also, how do class member variables fit in the mix?
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    John Smith Jr., Dec 22, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. shamanthakamani
    Replies:
    1
    Views:
    3,555
    Natty Gur
    Nov 20, 2003
  2. =?Utf-8?B?RGFiYmxlcg==?=

    browser refresh effect on session variables and view state?

    =?Utf-8?B?RGFiYmxlcg==?=, Aug 7, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    842
    Kumar Reddi
    Aug 8, 2006
  3. jnickfl1
    Replies:
    0
    Views:
    637
    jnickfl1
    Sep 18, 2006
  4. archana
    Replies:
    0
    Views:
    377
    archana
    Mar 13, 2007
  5. Parthiv Joshi
    Replies:
    1
    Views:
    825
    Samuel L Matzen
    Jul 6, 2004
Loading...

Share This Page