HttpResponse.AddFileDependencies Method (ArrayList)
.NET Framework 2.0
Adds a group of file names to the collection of file names on which the current response is dependent.
Namespace: System.Web
Assembly: System.Web (in system.web.dll)
Assembly: System.Web (in system.web.dll)
The following code example is an ASP.NET page that is output cached. The code for the page creates an ArrayList of file paths, then passes the ArrayList as the parameter in a call to the AddFileDependencies method. This makes the output cached response invalid if any of the files specified in the ArrayList changes.
<%@ Page Language="vj#" %>
<%@ outputcache duration="30" varybyparam="none" %>
<%@ Import Namespace="Samples.AspNet.JSL" %>
<script runat="server">
private void Page_Load(Object sender, System.EventArgs e)
{
// Create variables and assign file paths to them.
String file1 = get_Server().MapPath("authors.xml");
String file2 = get_Server().MapPath("books.xml");
// Create an array list to contain the file paths.
ArrayList fileList = new ArrayList();
fileList.Add(file1);
fileList.Add(file2);
// Make the page dependent upon the arrayList.
get_Response().AddFileDependencies(fileList);
// Populate the DataGrids.
dgAuthors.set_DataSource(DataHelper.GetAuthorData());
dgAuthors.DataBind();
dgBooks.set_DataSource(DataHelper.GetBookData());
dgBooks.DataBind();
lblOutputCacheMsg.set_Text(DateTime.get_Now().ToString());
} //Page_Load
</script>
<HTML>
<HEAD>
<title>PageDataDisplay</title>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<table>
<tr>
<th style="WIDTH: 118px">
Authors
</th>
<td>
<asp:DataGrid id="dgAuthors" runat="server"></asp:DataGrid>
</td>
<tr>
<th style="WIDTH: 118px">
Books
</th>
<td>
<asp:DataGrid id="dgBooks" runat="server"></asp:DataGrid>
</td>
</tr>
<tr>
<td style="WIDTH: 118px">
The page was generated at:
</td>
<td>
<asp:Label id="lblOutputCacheMsg" runat="server"></asp:Label>
</td>
</tr>
</table>
</form>
</body>
</HTML>
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.
Community Additions
ADD
Show: