ControlCachePolicy::Duration Property
Gets or sets the amount of time that cached items are to remain in the output cache.
Assembly: System.Web (in System.Web.dll)
| Exception | Condition |
|---|---|
| HttpException | The user control is not associated with a BasePartialCachingControl and is not cacheable. - or - The Duration property is set outside of the initialization and rendering stages of the control. |
If an absolute expiration policy is set using the SetSlidingExpiration method, the Duration property returns the amount of time remaining until cache entry expiration.
The following code example demonstrates how a user control can be loaded dynamically and manipulated programmatically at run time. The PartialCachingAttribute attribute is applied to a user control named SimpleControl, which means it is wrapped by a PartialCachingControl control at run time. The SimpleControl object's caching settings can be programmatically manipulated through its associated ControlCachePolicy object, which is available through a reference to the PartialCachingControl control that wraps it. In this example, the Duration property is examined during page initialization and cache expiration is changed if some conditions are met. This example is part of a larger example provided for the ControlCachePolicy class.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.