p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning ASP.NET 4 : in C# and VB (http://p2p.wrox.com/forumdisplay.php?f=560)
-   -   The View State Issue (http://p2p.wrox.com/showthread.php?t=86449)

vbboyd January 24th, 2012 11:32 AM

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.

vbboyd January 24th, 2012 11:37 AM

Quote:

Originally Posted by vbboyd (Post 280705)
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?

Imar January 27th, 2012 10:06 AM

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


All times are GMT -4. The time now is 10:17 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.