HttpCachePolicy.SetNoStore Method
.NET Framework 2.0
Sets the Cache-Control: no-store HTTP header.
Namespace: System.Web
Assembly: System.Web (in system.web.dll)
Assembly: System.Web (in system.web.dll)
The following code example demonstrates how to use the SetNoStore method of the HttpCachePolicy class to direct the client not to store the responses in its history.
<%@ Page language="c#" AutoEventWireup="true" %> <HTML> <HEAD> <title>HttpCachePolicy - SetNoStore - C# Example</title> <script runat="server"> void Page_Load(Object sender, EventArgs e) { // Prevent the browser from caching the ASPX page Response.Cache.SetNoStore(); // Display the DateTime value. Label1.Text = DateTime.Now.ToLongTimeString(); } </script> </HEAD> <body> <form id="Form1" method="post" runat="server"> <h3>HttpCachePolicy - SetNoStore - C# Example</h3> <P>Click the Submit button a few times, and then click the Browser's Back button.<BR> You should get a "Warning: Page has Expired" error message.</P> <P>Time: <asp:Label id="Label1" runat="server" Font-Bold="True" ForeColor="Red" /></P> <asp:Button id="Button1" runat="server" Text="Submit" /> </form> </body> </HTML>
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.