How to use output caching in asp.net

Ranjeet_8
Posted by Ranjeet_8 under ASP.NET category on | Points: 40 | Views : 1264

<%@ OutputCache Duration="120" VaryByParam="None" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Testing Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Font-Size="Larger" ForeColor="Green" Text="Output Caching Duration Is 120 seconds.">
</asp:Label>
<br /><br />
<asp:Label ID="Label2" runat="server" Font-Size="Larger" ForeColor="Red" >
</asp:Label>
<br />Press F5 to Refresh the page (Time will change after 120 sec)
</div>
</form>
</body>
</html>

Add This code on Page Load Event

Label2.Text = "Present Time: ";
Label2.Text += DateTime.Now.ToString();

Comments or Responses

Login to post response