viewstate question

  • Thread starter Thread starter Craig Buchanan
  • Start date Start date
C

Craig Buchanan

I'm using a viewstate key/value to store a serialized instance of a class.
If I redirect to another aspx page, the viewstate is lost. Is this the
intended behavior of the viewstate? Is there a work around? Cookies, I
suppose.

Thanks,

Craig Buchanan
 
Hi,

by default ViewState is page-specific. And yes, it is designed to be so.
Workaround can be basically anything where you can serialize your class
instance like cookie (means just serilalization to string in that case).
Easiest way to get over it would be using Session as in InProc mode it can
hold any class instance without serializing.
 
hi,
ViewSate works on "hidden" textboxes placed on a particular page
i.e pageSpecific
if u want to maintain state over pages. then there
are:
Session and
Cookies to rely on ..
there is also the Cache class to work witth
which can persist over pages.

bye

amit
 
Amit-

Thanks for the response. Two questions:

1) are .Net session objects scalable?
2) what are the pros/cons for a cache class?

Thanks,

Craig
 
Persisting data is a real problem in ASP.Net due to the stateless nature of
HTTP. When talking about persisting a value, you need to think about scope.
How long do you want the variable to exist? What should it be exposed to?
For example, should it have Application Scope, so that any page being viewed
by any user can access it? Should it be in Session State, so that each user
has their own separate variable that remains for the lifetime of the User
Session? Should it have Page scope, such as ViewState, so that it is
persisted only for the duration of the current Page and PostBacks of that
Page? Should it be stored in a database, where it will persist permanently,
and is still avialable to any Page that needs it for any user? The more
carefully you consider this question, the less you'll have to change later.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
no,
in a web app there are hundreds of users hitting a site..
so ifu put everything in session say ten variables in session
so for 100 users i will multiply
and so that much load on the server.
so one shud uses session sparingly

for imp tasks only like
username.

where r u from ..

amit agarwal
india
 
Back
Top