CacheKeyDependency Property

SqlDataSource.CacheKeyDependency Property

Gets or sets a user-defined key dependency that is linked to all data cache objects that are created by the data source control. All cache objects are explicitly expired when the key is expired.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

public virtual string CacheKeyDependency { get; set; }
<asp:SqlDataSource CacheKeyDependency="String" />

Property Value

Type: System.String
A key that identifies all cache objects created by the SqlDataSource.

The SqlDataSource control supports data caching. While data is cached, the Select method retrieves data from the cache rather than from the underlying database. When the cache expires, the Select method retrieves data from the underlying database, and then caches the data again.

You can set the CacheKeyDependency property to create a dependency between all cache entries that are created by the SqlDataSource control and the key. You can programmatically expire all the cache entries at any time by expiring the key.

The SqlDataSource control can cache data only when in the DataSet mode. A NotSupportedException exception is thrown by the Select method, if the SqlDataSource control is set to the DataReader value and caching is also enabled.

A unique cache entry is created for every combination of the SelectCommand, ConnectionString, and SelectParameters properties. Multiple SqlDataSource controls can use the same cache entries in scenarios where the controls load the same data from the same underlying database.

Security noteSecurity Note:

When you are using client impersonation under Microsoft Windows authentication, the data is cached when the first user accesses the data. If another user requests the same data, the data is retrieved from the cache. The data is not retrieved by making another call to the database to verify the user's access to the data. If you expect more than one user to access the data, and you want each retrieval to the data to be verified by the security configurations for the database, do not use caching.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0

Community Additions

ADD
Show:
© 2016 Microsoft