Cache ASP.Net Tutorial

File: Default.aspx
<%@ Page Language="C#" %>
<%@ OutputCache Duration="3600" VaryByParam="none" %>
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


    Product List


    
    

    <%= DateTime.Now.ToString("T") %>
    
            id="grdProducts"
        DataSourceID="srcProducts"
        Runat="server" />
            id="srcProducts"
        ConnectionString="<%$ ConnectionStrings:Products %>"
        SelectCommand="SELECT Title, Director FROM Products"
        Runat="server" />
    
    Add Product
    

    


File: NextPage.aspx
<%@ Page Language="C#" %>
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    protected void dtlProduct_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
    {
        HttpResponse.RemoveOutputCacheItem(Page.ResolveUrl("~/Default.aspx"));
        Response.Redirect("~/Default.aspx");
    }



    Add Product


    
    

    

Add Product


            id="dtlProduct"
        DefaultMode="Insert"
        DataSourceID="srcProducts"
        AutoGenerateRows="false"
        AutoGenerateInsertButton="true"
        Runat="server" OnItemInserted="dtlProduct_ItemInserted">
        
                    DataField="Title"
            HeaderText="Title:" />
                    DataField="Director"
            HeaderText="Director:" />
        

    
            id="srcProducts"
        ConnectionString="<%$ ConnectionStrings:Products %>"
        InsertCommand="INSERT Products (Title, Director)
            VALUES (@Title, @Director)"
        Runat="server" />