结果图:
<script runat="server">
static string getCurrentTime(HttpContext context)
{
return DateTime.Now.ToString();
}
void Page_Load(object sender, EventArgs e)
{
Response.Cache.SetExpires(DateTime.Now.AddSeconds(20));
Response.Cache.SetCacheability(HttpCacheability.Public);
Response.Cache.SetValidUntilExpires(true);
}
</script>
<div>
<h4>
在缓存页面插入动态内容--使用substitution控件演示</h4>
<p>
Cache Time:<%= DateTime.Now.ToString() %>
</p>
<p>
<b>Real Time:<asp:Substitution ID="Substitution1" runat="server" MethodName="getCurrentTime" />
</b>
</p>
</div>
<%@ OutputCache Duration="600" VaryByParam="none" %>
<script runat="server">
static string getCurrentTime(HttpContext context)
{
return DateTime.Now.ToString();
}
</script>
<div>
<h4>
在缓存页面插入动态内容--使用substitution控件演示</h4>
<p>
Cache Time: <%= DateTime.Now.ToString() %>
</p>
<p>
<b>Real Time:<asp:Substitution ID="Substitution1" runat="server" MethodName="getCurrentTime" />
</b>
</p>
</div>