<%@ outputcache duration="30" varybyparam="none" %> <script runat="server" language="VB"> Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) CachedDate.Text = DateTime.Now.ToString() End Sub
Shared Function GetCurrentDate(ByVal context As HttpContext) As String Return DateTime.Now.ToString() End Function </script> <html> <head id="Head1" runat="server"> <title>substitution例子</title> </head> <body> <form id="Form1" runat="server"> <p>下面的时间显示没有使用缓存功能</p> <asp:substitution id="Substitution1" methodname="GetCurrentDate" runat="Server"> </asp:substitution> 下面的时间显示使用了缓存功能,只有在30秒后才改变: