Rafael Emshoff
Rafael Emshoff

Reputation: 2729

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

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?

Upvotes: 0

Views: 894

Answers (1)

RB.
RB.

Reputation: 37192

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.

Upvotes: 3

Related Questions