HI all,
Where can I find documentation on best practices about whether or not to put
usercontrols into either viewstate or session variables. What are the pro's
and cons and if this type of practice is acceptable or frowned upon.
Thanks
Robert
tzarpho - 27 Feb 2008 12:12 GMT
Here are some resources courtesy of a quick Google search:
General design approach:
http://forums.asp.net/t/1223582.aspx
A nice summary of viewstate:
http://aspalliance.com/articleViewer.aspx?aId=135&pId=
A more in-depth article on viewstate:
http://aspnetresources.com/articles/ViewState.aspx
Backgrounder on viewstate versus session:
http://forums.asp.net/p/1147538/1865335.aspx#1865335
Comprehensive reference on Understanding ASP.NET View State
http://msdn2.microsoft.com/en-us/library/ms972976.aspx
Q&A on viewstate verus session:
http://www.velocityreviews.com/forums/t71973-q-questions-about-viewstate-versus-
session.html
Generally, the approach is to use viewstate preferably because session
adversely affects performance - holding user control states beyond the
point their relevant is an obvious risk when using session - but if
page load begins to suffer under the weight of a larger viewstate then
it's time to look at the alternatives. Anybody want to chime in with
solutions for page bloat?
Kofi Sarfo
Peter Bromberg [C# MVP] - 27 Feb 2008 12:20 GMT
Robert,
This is really an ASP.NET newsgroup question, not a c# language group one.
In general, it's not a good idea to attempt to store an entire control
object in either ViewState or Session. You should store values - simple types.
Viewstate only works for the same page, to persist through a postback.
Session works user-specific and persists across multiple page requests.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short Urls & more: http://ittyurl.net
> HI all,
>
[quoted text clipped - 4 lines]
> Thanks
> Robert