2014-11-24 31 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。