HttpCachePolicy.SetNoStore Methode
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Legt den Cache-Control: no-store
-HTTP-Header fest.
public:
void SetNoStore();
public void SetNoStore ();
member this.SetNoStore : unit -> unit
Public Sub SetNoStore ()
Beispiele
Im folgenden Codebeispiel wird veranschaulicht, wie Sie die SetNoStore -Methode der HttpCachePolicy -Klasse verwenden, um den Client anweisen, die Antworten nicht im Verlauf zu speichern.
<%@ Page language="c#" AutoEventWireup="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<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>
<%@ Page language="VB" AutoEventWireup="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<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>
Gilt für:
Feedback
https://aka.ms/ContentUserFeedback.
Bald verfügbar: Im Laufe des Jahres 2024 werden wir GitHub-Issues stufenweise als Feedbackmechanismus für Inhalte abbauen und durch ein neues Feedbacksystem ersetzen. Weitere Informationen finden Sie unterFeedback senden und anzeigen für