asp.net 缓存小实例
將下面二行代碼放入用戶控件
<%@ OutputCache Duration="60" VaryByParam="none" %>
<%=DateTime.Now %>
在aspx頁中引入
<%@ Register Src="~/userControl/FanChueng.ascx" TagName="WebUserControl1" TagPrefix="uc1" %>
<div>
页面的:<%=DateTime.Now %>
</div>
<div>
控件的:<uc1:WebUserControl1 ID="WebUserControl11" runat="server" />
</div>
以上代碼是頁面的局部緩存!在用戶控件里使用<OutputCache Duration="60(秒為單位)"
在頁面中用戶控件在60秒不會改變時間
------------------------------------------------------
<%@ OutputCache Duration="60" VaryByParam="none" %>
<%=DateTime.Now %>
在aspx頁中引入
<%@ Register Src="~/userControl/FanChueng.ascx" TagName="WebUserControl1" TagPrefix="uc1" %>
<div>
页面的:<%=DateTime.Now %>
</div>
<div>
控件的:<uc1:WebUserControl1 ID="WebUserControl11" runat="server" />
</div>
以上代碼是頁面的局部緩存!在用戶控件里使用<OutputCache Duration="60(秒為單位)"
在頁面中用戶控件在60秒不會改變時間
------------------------------------------------------
浙公网安备 33010602011771号