SgDotNet
Singapore Professional .NET User Group -For Cool Developers

How to clear @outputcache of user controls?

rated by 0 users
This post has 4 Replies | 2 Followers

Top 500 Contributor
Posts 2
ckiang Posted: 11-23-2006 10:01 PM

Hi,

Can any of the experts here help me with this?  I have an aspx page with a few user controls which has the <%outputcache%> set to cache the for anything between 30s to an hour depending on the nature of their content. While clearing the outputcache of a page is relatively easy, I can't seem to find a way to clear the cache for User Controls. I've tried the code given here http://www.syncfusion.com/FAQ/aspnet/WEB_c25c.aspx as well as other places (there aren't many anyway) and they doesn't seem to work. 

Many thanks in advance.

Regards
CK

Top 50 Contributor
Posts 47

Try to call HttpResponse.RemoveOutputCacheItem("< virtual path of your user control>"); in non output-cached page. You can use Response.Cache.AddValidationCallback() as alternative too.

 

Hope this helps...

- Alvin Chooi, Malaysia - Microsoft ASP.NET™ Enthusiast - URL: http://forums.asp.net Blog: http://alvinzc.blogspot.com
Top 500 Contributor
Posts 2

Hi,

Tried the HttpResponse.RemoveOutputCacheItem() but it appears to work only with .aspx pages, not UserControls. :(

Regards
CK

Top 10 Contributor
Posts 2,284

Have you tried

Cache.Remove(myUserControl.UniqueID)

If that is not the correct cache key, you may have to resort to using the Cache Viewer tool (below) to determine the exact key name used by the ASP.NET runtime

http://authors.aspalliance.com/aldotnet/examples/cacheviewer.aspx

The melody of logic will always play out the truth. ~ Narumi Ayumu, Spiral

Top 150 Contributor
Posts 15

hi, 

can you try following

me.Cache.Remove(me.ClientID.ToString())

.Cache.Remove(me.ClientID.ToString())

 

regards,

satish

Page 1 of 1 (5 items) | RSS
Copyright SgDotNet 2004-2008
Powered by Community Server (Commercial Edition), by Telligent Systems