Wrox Programmer Forums
|
BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio
This is the forum to discuss the Wrox book ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solution by Vincent Varallo; ISBN: 9780470396865
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio 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 April 21st, 2009, 04:02 PM
Authorized User
 
Join Date: Apr 2009
Posts: 41
Thanks: 1
Thanked 2 Times in 2 Posts
Default ViewState vs Caching

I was wondering if there was a particular reason for choosing to use ViewState rather than cache to store the objects?

The application I'm developing may have lots of information in the objects - just the simple tests I've done so far have take up a large chunk of the page for the ViewState.

Was there a design consideration (that maybe I missed in the book) for this, or was it a personal choice?

Generally, I try to avoid ViewState like the plague (along with Session), so it could be that I'm just unreasonably biased.

Tim
 
Old April 21st, 2009, 06:06 PM
Friend of Wrox
 
Join Date: Jun 2007
Posts: 477
Thanks: 10
Thanked 19 Times in 18 Posts
Default

I agree. ViewState tends to get out of control quickly. I too would be interested to see if there's a reason, or if it just made for easier to understand examples. (That's one of the things I don't like about MSDN is how it explains best practices but then uses SqlDataSource in all the examples.) :(
__________________
-------------------------

Whatever you can do or dream you can, begin it. Boldness has genius, power and magic in it. Begin it now.
-Johann von Goethe

When Two Hearts Race... Both Win.
-Dove Chocolate Wrapper

Chroniclemaster1, Founder of www.EarthChronicle.com
A Growing History of our Planet, by our Planet, for our Planet.
 
Old April 22nd, 2009, 11:49 AM
Authorized User
 
Join Date: Dec 2008
Posts: 29
Thanks: 1
Thanked 5 Times in 5 Posts
Default

Using MVC is one way :).
 
Old April 28th, 2009, 03:18 PM
Authorized User
 
Join Date: Mar 2009
Posts: 79
Thanks: 4
Thanked 4 Times in 4 Posts
Default

Quote:
Originally Posted by AspNew View Post
Using MVC is one way :).
The book that Vince has put together is in a nutshell MVC if you compare what he has done against the MVC model.

MVC meaning Model, View, Controller is the same three layer process that Vince followed. The issue of ViewState vs Cache is purely choice and has nothing to do with software architectural pattern. To me they both accomplish the samething.

With that being cleared up and correct me if Im wrong.
To me Viewstate is my preferred choice from a security standpoint. Cache can be comprimised after the page no longer exists. With ViewState it only exists on that one page while that page is present. So if you go to a new page no more data, with Cache you get easier access to the data but it exists until you destroy it.
 
Old April 28th, 2009, 04:51 PM
Authorized User
 
Join Date: Apr 2009
Posts: 41
Thanks: 1
Thanked 2 Times in 2 Posts
Default

Wouldn't you be able to overcome the security issue with a little extra code? Perhaps in the global.asax's Application_End? Just call Cache.Remove(key) for each item in the cache.

Or set an expiration on the data in the cache (going off the top of my head here; don't remeber the exact way to do that).

For me, unless the page is light on controls and/or data, I prefer to avoid ViewState, but that's just a personal preference. At least until someone convinces me solidly one way or the other. :)

Tim
 
Old April 30th, 2009, 12:17 PM
Authorized User
 
Join Date: Mar 2009
Posts: 79
Thanks: 4
Thanked 4 Times in 4 Posts
Default

Quote:
Originally Posted by Corsair View Post
Wouldn't you be able to overcome the security issue with a little extra code? Perhaps in the global.asax's Application_End? Just call Cache.Remove(key) for each item in the cache.

Or set an expiration on the data in the cache (going off the top of my head here; don't remeber the exact way to do that).

For me, unless the page is light on controls and/or data, I prefer to avoid ViewState, but that's just a personal preference. At least until someone convinces me solidly one way or the other. :)

Tim
Tim you are right, that is why I said that it is more of a preferred thing than a right vs wrong thing. I havent seen anything that is totally against it that had factual backing vs opionated backing.
That is the great thing about programming for Windows and the Windows platform altogether. There are multiple ways to do the same thing.
Have a good one.

DJ
 
Old April 29th, 2010, 05:16 AM
Authorized User
 
Join Date: Nov 2009
Posts: 31
Thanks: 3
Thanked 0 Times in 0 Posts
Default <sessionState mode="Off" />

I disabled the session at all. now I can do web farming on my UI layer for scalibility and performance. no need for any state server for session. just compress your view state before storing if you are woried of page size.
__________________
Syed Hassan Abbas
Thorns road
Astley bridge, Bolton, UK
Mob: +44 (0) 7761503471





Similar Threads
Thread Thread Starter Forum Replies Last Post
Caching stu9820 ASP.NET 3.5 Basics 0 June 20th, 2008 03:20 PM
caching jezywrap ASP.NET 2.0 Professional 0 February 27th, 2007 05:00 PM
Caching Amateur BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 February 9th, 2007 02:50 PM
caching? freaknfreak HTML Code Clinic 1 January 24th, 2006 12:10 PM
Caching bmains ASP.NET 1.x and 2.0 Application Design 4 February 27th, 2004 09:06 AM





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