To substitute the cache for a particular widget, you create a custom cache substitution widget and place it on the page. The widget utilizes the ASP.NET cache substitution. You create a static method that registers with the ASP.NET implementation of cache substitution. Inside this method, you must render the content of the widget.
Create a User widget with the following markup:
If the widget, you want to substitute, inherits from SimpleView, which in turn inherits from System.Web.UI.WebControls.WebControl, you can override the RenderContents(System.Web.UI.HtmlTextWriter writer) method. Inside, you call your own implementation for performing cache substitution.
SimpleView
System.Web.UI.WebControls.WebControl
RenderContents(System.Web.UI.HtmlTextWriter writer)
When output cache is used on the page, you substitute it with the CacheSubstitutionWrapper in DoPostCacheSubstitution() method by forming a dictionary of parameters and passing it to a CacheSubstitutionWrapper.RenderMarkupDelegate that afterwards renders the correct markup.
CacheSubstitutionWrapper
DoPostCacheSubstitution()
CacheSubstitutionWrapper.RenderMarkupDelegate
IMPORTANT: Do not pass entire objects, such as a page, a control instance, property of the control, etc. This will cause serious memory leaks. When you need to pass a property value, you must use its string representation.
Following is a code sample of the code-behind file:
Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.
This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.
This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.
The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important