System.Web.UI.ControlCachePolicy Class

Provides programmatic access to an ASP.NET user control's output cache settings.

See Also: ControlCachePolicy Members

Syntax

public sealed class ControlCachePolicy

Remarks

The System.Web.UI.ControlCachePolicy class is used by developers in programmatic user control scenarios to specify output caching settings for user controls (.ascx files). ASP.NET embeds user controls within a System.Web.UI.BasePartialCachingControl instance. The System.Web.UI.BasePartialCachingControl class represents a user control that has output caching enabled. When you access the BasePartialCachingControl.CachePolicy property of a System.Web.UI.PartialCachingControl control, you will always receive a valid System.Web.UI.ControlCachePolicy object. However, if you access the UserControl.CachePolicy property of a System.Web.UI.UserControl control, you receive a valid System.Web.UI.ControlCachePolicy object only if the user control is already wrapped by a System.Web.UI.BasePartialCachingControl control. If it is not wrapped, the System.Web.UI.ControlCachePolicy object returned by the property will throw exceptions when you attempt to manipulate it because it does not have an associated System.Web.UI.BasePartialCachingControl. To determine whether a System.Web.UI.UserControl instance supports caching without generating exceptions, inspect the ControlCachePolicy.SupportsCaching property.

Using the System.Web.UI.ControlCachePolicy class is one of several ways you can enable output caching. The following list describes methods you can use to enable output caching:

Requirements

Namespace: System.Web.UI
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0