views:

201

answers:

2

I was looking at this article from 2005 and wanted to get some thoughts on it, advantages and disadvantages that the article does not point out about ViewState and Cache?

http://www.codersource.net/asp_net_viewstate_versus_data_caching.aspx

+1  A: 

ViewState is used per-user, you don't store a ViewState to use on another use. A Cache is "global" and is accessed by all users, depending on how you Index the Cache of course.

I use both ViewState and Cache on a lot of my sites because ViewState handles when i postback stuff with my gridviews and such and the Cache is used for Chaching everything that is partially or fully static.

Filip Ekberg
+2  A: 

That article is poor - why confuse the Cache and Viewstate in the same article? It's like saying 'in this article I compare the car and the can opener... conclusion: choose which best suits your needs'. I would ignore that for starters.

For most users starting out with ASP.NET, viewstate can be completely disabled. Here is a proper article explaining Viewstate (and more generally the page lifecycle):

http://msdn.microsoft.com/en-us/library/ms972976.aspx

Caching on the otherhand is an essential technique for improving performance of both individual page requests and a site as a whole.

flesh
Looks like a lot of articles compare ViewState, Session, Cache, etc, so does this mean they are all rubbish?
Xaisoft
Comparing them isn't all that "rubbish" but you need to Clearly state that they are used for Completely different things.
Filip Ekberg
saying 'viewstate and the cache are both means of storing data' is true, in the loosest possible sense, but they do totally different things and have entirely different uses. Comparing Session and Cache on the otherhand is entirely valid, they do similar things but with subtle differences.
flesh
... 'A couple of days ago I ran into a confusion when I had to decide that whether to use ViewState or Data Caching' - if he is deciding between these, he most certainly is confused.
flesh