Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / February 2008

Tip: Looking for answers? Try searching our database.

Best Practice - viewstate / session

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Robert Bravery - 27 Feb 2008 08:20 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.