Why isn't caching (System.Web.Caching.Cache) used for state management?
Asked Answered
W

1

0

I'm trying to understand the accepted answer for Persisting DataSource in GridView after PostBack as I have a similar problem.

Quote:

I steer clear of putting stuff into the VeiwState or session unnecessarily, so I think the best way to persist this data is to Cache it.

When I look at the MS suggestions for state management: ASP.NET State Management Overview caching is no where to be seen. There is a comment (search for Jim_Huff), asking about this, but it isn't answered.

Question: What's the deal with cache in this context - should I use it or not?

Wafd answered 14/3, 2013 at 11:34 Comment(0)
H
3

The answer to that question was supplied by the question author, and it is not a very good answer.

State management is for managing the state of a single session. There are safeguards to ensure that you do not trample over other user's session state, and well-defined mechanisms for scavenging old sessions, abandoning sessions, etc.

The application cache is for managing the global state of the entire application. It's not appropriate to use it for managing session state.

Heliogabalus answered 14/3, 2013 at 11:41 Comment(2)
So... state management maps to a designated part of the cache, reserved for session/view/page specific data - or is it completely separated?Wafd
The two are completely separate. Your session state exists in your session state database (which could be in-memory, a SQL database, or a StateServer). The application cache is a completely different database (which, again, could be in-memory, or a SQL database, or something else, depending on your specific caching technology)Heliogabalus

© 2022 - 2024 — McMap. All rights reserved.