Page.Cache vs HttpContext.Current.Cache

  • Thread starter Thread starter DesignerX
  • Start date Start date
D

DesignerX

What is the difference between Page.Cache and HttpContext.Current.Cache? Do
these access the same thing? Is there any easy way to clear all items in the
cache?

TIA,

Stan
 
They are the same thing.

There is no Clear method for the Cache, so you would have to loop through it
and call Remove on each item to clear it.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
I haven't had any luck with the remove method. What will work is something
like the following
Cookie = New HttpCookie("yourcookieidtoremove")
Cookie.Values.Add("yourcookievalueName,"")
cookie.expires=datetime.now.adddays(-5)
HttpContext.Current.Response.Cookies.add(Cookie)

This method will remove the cookie
 
I don't recall anything in the question about cookies....

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
vMike said:
I haven't had any luck with the remove method. What will work is something
like the following
Cookie = New HttpCookie("yourcookieidtoremove")
Cookie.Values.Add("yourcookievalueName,"")
cookie.expires=datetime.now.adddays(-5)
HttpContext.Current.Response.Cookies.add(Cookie)

This method will remove the cookie

Cookies have nothing to do with the cache.
 
Sorry, you're right. I thought I saw cookie. This will work

dim objItem as DictionaryEntry
dim strName as String

For Each objItem In Cache
strName = objItem.Key.tostring()
cache.remove(strName)
Next
 
Back
Top