Control Sitefinity caching from Widget / Usercontrol / Custom code
Hi everyone,
We have some widgets that prefer pages that don't use caching. Sometimes we forget to set this caching option to "none", and then data doesn't show as it should. Is there an option to set the caching settings/option of a page, through a widget that is dragged on to that page?
Best regards, Tys
Hi Tys,
You can set the Page cacheability directly from your user control, for example by plugging in the OnInit event and saying:
protected
override
void
OnInit(EventArgs e)
this
.Context.Response.DisableKernelCache();
this
.Context.Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
base
.OnInit(e);
This seems to update the cache on the entire page, not just the user control.
Looks like what i needed!
Is there a way to do the same thing for the "Enable ViewState" setting?
Thanks!