CacheDependency.HasChanged Property

Gets a value indicating whether the CacheDependency object has changed.

Namespace: System.Web.Caching
Assembly: System.Web (in system.web.dll)

public:
property bool HasChanged {
	bool get ();
}
/** @property */
public boolean get_HasChanged ()

public function get HasChanged () : boolean

Not applicable.

Property Value

true if the CacheDependency object has changed; otherwise, false. The default is false.

You can add an item to an ASP.NET application's Cache with a CacheDependency. When the CacheDependency changes, the item added to the Cache is invalidated and removed from the cache. You can use this property to determine whether a CacheDependency has changed, and recreate the item in the Cache if that has occurred.

The following code example demonstrates using the HasChanged property to determine whether a CacheDependency changed since the previous request for an item in the Cache. The dt value passed in the start parameter is set to DateTime.Now.

No code example is currently available or this language may not be supported.
// Insert the cache item.
CacheDependency dep =  new CacheDependency(fileName, dt);
cache.Insert("key", "value", dep);

// Check whether CacheDependency.HasChanged is true.
if (dep.get_HasChanged()) {
    get_Response().Write("<p>The dependency has changed.");
}
else {
    get_Response().Write("<p>The dependency has not changed.");
} 

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show: