By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,414 Members | 1,057 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,414 IT Pros & Developers. It's quick & easy.

Session and View State variables

P: n/a
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?
Nov 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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." <me@isp.com> wrote in message
news:eX*************@tk2msftngp13.phx.gbl...
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?

Nov 18 '05 #2

P: n/a
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]" <St***@Orr.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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." <me@isp.com> wrote in message
news:eX*************@tk2msftngp13.phx.gbl...
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?


Nov 18 '05 #3

P: n/a
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." <me@isp.com> wrote in message
news:eB**************@TK2MSFTNGP12.phx.gbl...
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]" <St***@Orr.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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." <me@isp.com> wrote in message
news:eX*************@tk2msftngp13.phx.gbl...
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?



Nov 18 '05 #4

P: n/a
Ahh, thank you much.
"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message
news:eq**************@TK2MSFTNGP10.phx.gbl...
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." <me@isp.com> wrote in message
news:eB**************@TK2MSFTNGP12.phx.gbl...
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]" <St***@Orr.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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." <me@isp.com> wrote in message
news:eX*************@tk2msftngp13.phx.gbl...
> 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?
>
>



Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.