HttpResponse.AddFileDependency(String) Method

Definition

Adds a single file name to the collection of file names on which the current response is dependent.

C#
public void AddFileDependency(string filename);

Parameters

filename
String

The name of the file to add.

Examples

The following example shows how to add a single file name to the AddFileDependency file dependency list. If the file changes, the cached response is invalidated.

C#
String FileName;
 FileName = "C:\\Files\\F1.txt";
 Response.AddFileDependency(FileName);

Remarks

When you use the AddFileDependency method to add a file dependency, you must also specify output caching programmatically or declaratively. For example, to specify output caching declaratively, use the @ OutputCache directive. For more information, see How to: Cache Page Output with File Dependencies.

Applies to

Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also