2014-11-24 33 views
0
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" 
    CodeFile="Default.aspx.cs" Inherits="_Default" %> 

<%@ OutputCache Duration="10" Location="Server" VaryByParam="none" %> 

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"> 
</asp:Content> 
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> 
    <h2> 
     Welcome to ASP.NET! 
    </h2> 
    <p> 
     To learn more about ASP.NET visit <a href="http://www.asp.net" title="ASP.NET Website"> 
      www.asp.net</a>. 
    </p> 
    <p> 
     This is cached date text 
     <asp:Label ID="lblDate" runat="server"></asp:Label> 
    </p> 
    <p> 
     This is uncached date text 
     <asp:Label ID="lblDate1" EnableViewState="false" runat="server"></asp:Label> 
    </p> 
    <p> 
     You can also find <a href="http://go.microsoft.com/fwlink/?LinkID=152368&amp;clcid=0x409" 
      title="MSDN ASP.NET Docs">documentation on ASP.NET at MSDN</a>. 
    </p> 
</asp:Content> 

在上面的代碼中,我想,只有lblDate1值應該改變,每當我將刷新我怎麼能acheive this.Currently兩個控制值歌廳cahced的頁面。如何保持uncahced頁的小部分頁面進行放緩存

回答

0

由於頁面被緩存,所以整個頁面都被緩存了,這個調用中的任何內容都不會被再次從服務器中獲取,直到緩存失效。

您可以通過在文檔加載中使用JavaScript執行ajax調用來解決此問題,該方法從REST服務獲取更新值(或通過從aspx頁面返回json格式的字符串來模擬服務),然後更新日期值從JavaScript。