Freigeben über


HttpCachePolicy.SetNoStore-Methode

Legt den Cache-Control: no-store-HTTP-Header fest.

Namespace: System.Web
Assembly: System.Web (in system.web.dll)

Syntax

'Declaration
Public Sub SetNoStore
'Usage
Dim instance As HttpCachePolicy

instance.SetNoStore
public void SetNoStore ()
public:
void SetNoStore ()
public void SetNoStore ()
public function SetNoStore ()

Beispiel

Im folgenden Codebeispiel wird veranschaulicht, wie mithilfe der SetNoStore-Methode der HttpCachePolicy-Klasse der Client angewiesen wird, die Antworten nicht in dessen Verlauf zu speichern.

<%@ Page language="VB" AutoEventWireup="true" %>
<HTML>
  <HEAD>
    <title>HttpCachePolicy - SetNoStore - Visual Basic .NET Example</title>
    <script runat="server">
      Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) 
          
          ' Prevent the browser from caching the ASPX page.
          Response.Cache.SetNoStore()
          
          ' Display the DateTime value.
          Label1.Text = DateTime.Now.ToLongTimeString()
      End Sub  
  </script>
  </HEAD>
  <body>
    <form id="Form1" method="post" runat="server">
      <h3>HttpCachePolicy - SetNoStore - Visual Basic .NET 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>
<%@ 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>

Plattformen

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

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

HttpCachePolicy-Klasse
HttpCachePolicy-Member
System.Web-Namespace