HttpRuntime.Cache how to discard

179 Views Asked by At

I have a problem with an asp.net site (4.0 framework) I would like to understand how to properly discard of values in HttpRuntime.Cache between page requests. I am storing values for pagination , control state etc on a search page, and it works fine .. except the values for controls exist (eg. combo box selection) if i open a different browser and open the page.

2

There are 2 best solutions below

0
On

You should not be using Cache in this way. Not only is it cross-browser-window... it applies to the whole application.

You should use querystring/form values for saving which page is being viewed, instead.

0
On

If you want a storage per session, the HttpContext.Current.Session is a good place to put it. As Andrew Barber points out, the Cache is application-wide (shared by all users and sessions)