HttpResponse.AddFileDependencies Method (ArrayList)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

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)

Public Sub AddFileDependencies (
	filenames As ArrayList


Type: System.Collections.ArrayList

The collection of files to add.

The following example is an ASP.NET page that is output cached. The code for the page creates an ArrayList of file paths, and 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="vb" %>
<%@ outputcache duration="30" varybyparam="none" %>
<%@ Import Namespace="Samples.AspNet.VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<script runat="server">

    Private Sub Page_Load(sender As Object, e As System.EventArgs)

       ' Create variable and assign file paths to them.
       Dim file1 As String = Server.MapPath("authors.xml")
       Dim file2 As String = Server.MapPath("books.xml")

       ' Create an array list to contain the file paths.
       Dim fileList As New ArrayList()

       ' Use the AddFileDependencies method to
       ' invalidate the output cached page if 
       ' one of the files changes.

       ' Populate the DataGrids.
       dgAuthors.DataSource = DataHelper.GetAuthorData()

       dgBooks.DataSource = DataHelper.GetBookData()

       lblOutputCacheMsg.Text = DateTime.Now.ToString()
    End Sub


<html xmlns="" >
    <form id="Form1" method="post" runat="server">
                    <th style="WIDTH: 118px">
                        <asp:DataGrid id="dgAuthors" runat="server"></asp:DataGrid>
                    <th style="WIDTH: 118px">
                        <asp:DataGrid id="dgBooks" runat="server"></asp:DataGrid>
                    <td style="WIDTH: 118px">
                        The page was generated at:</td>
                        <asp:Label id="lblOutputCacheMsg" runat="server"></asp:Label>

.NET Framework
Available since 1.1
Return to top