Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 24th, 2012, 11:32 AM
Friend of Wrox
 
Join Date: May 2011
Posts: 411
Thanks: 13
Thanked 7 Times in 7 Posts
Default The View State Issue

On page 292 of your book you state:
"Removing the check for Page.IsPostback is enough to accomplish this. However this is not always the desired solution. Imagine that you are getting correct display direction from a database. Because the number of times that you hit a database can be a costly operation, you want to minimize the number of times that you hit the database."

My question to you would be is not Viewstate a pricely and cumbersome overhead to the overall footprint of the application as well? Can Viewstate not also have a tendency to gum up the works so to speak on any .NET application?

Thank you for your attention to this matter.
 
Old January 24th, 2012, 11:37 AM
Friend of Wrox
 
Join Date: May 2011
Posts: 411
Thanks: 13
Thanked 7 Times in 7 Posts
Default

Quote:
Originally Posted by vbboyd View Post
On page 292 of your book you state:
"Removing the check for Page.IsPostback is enough to accomplish this. However this is not always the desired solution. Imagine that you are getting correct display direction from a database. Because the number of times that you hit a database can be a costly operation, you want to minimize the number of times that you hit the database."

My question to you would be is not Viewstate a pricely and cumbersome overhead to the overall footprint of the application as well? Can Viewstate not also have a tendency to gum up the works so to speak on any .NET application?

Thank you for your attention to this matter.
I guess maybe I should clarify my question just a bit more. The real question becomes what factors do you use to balance using viewstate as opposed to hitting the database? Are there any hard and fast rules in .NET for any of this when making these considerations?
 
Old January 27th, 2012, 10:06 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
Are there any hard and fast rules in .NET for any of this when making these considerations?
No. You need to outweigh the pros and cons. If it's not directly clear, you'll need to measure performance and network trafic.

A complex number that takes 1 minute to calculate but only takes up the size of an integer is a good candidate to store in ViewState (if it doesn't have to be updated each time). A DataSet with 4000 records is clearly not a good candidate to store in ViewState. You could store it in the Cache, recreate it after each postback, or find ways to query fewer records on each call (but still not store them in ViewState).

Hope this helps a bit.

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
View state problem rabbit3 ASP.NET 2.0 Professional 0 October 23rd, 2007 08:55 PM
Javascript and View State VictorVictor ASP.NET 2.0 Professional 8 April 2nd, 2007 02:34 PM
Session State|View State|Do I have other options? rockon ASP.NET 1.x and 2.0 Application Design 2 October 5th, 2005 07:10 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.