Session and View State variables

  • Thread starter Thread starter John Smith Jr.
  • Start date Start date
J

John Smith Jr.

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?
 
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.
 
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 said:
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. said:
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?
 
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. said:
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 said:
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. said:
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?
 
Ahh, thank you much.


Hermit Dave said:
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. said:
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 said:
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




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?
 
Back
Top