Export (0) Print
Expand All

HttpResponse.AddFileDependencies Method (ArrayList)

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 void AddFileDependencies (
	ArrayList filenames
)
public void AddFileDependencies (
	ArrayList filenames
)
public function AddFileDependencies (
	filenames : ArrayList
)

Parameters

filenames

The collection of files to add.

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="c#" %>
<%@ outputcache duration="30" varybyparam="none" %>
<%@ Import Namespace="Samples.AspNet.CS" %>

<script runat="server">

    private void Page_Load(object sender, System.EventArgs e) 
    {
		
        // Create variables and assign file paths to them.
        string file1 = Server.MapPath("authors.xml");
        string file2 = 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.
        Response.AddFileDependencies(fileList);

        // Populate the DataGrids.
        dgAuthors.DataSource = DataHelper.GetAuthorData();
        dgAuthors.DataBind();

        dgBooks.DataSource = DataHelper.GetBookData();
        dgBooks.DataBind();

        lblOutputCacheMsg.Text = DateTime.Now.ToString();

    }

</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>

<%@ 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.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft