HttpCachePolicy.SetAllowResponseInBrowserHistory メソッド
アセンブリ: System.Web (system.web.dll 内)

Dim instance As HttpCachePolicy Dim allow As Boolean instance.SetAllowResponseInBrowserHistory(allow)

HttpCacheability が NoCache または ServerAndNoCache に設定されている場合、Expires HTTP ヘッダーは既定で -1 に設定されます。この場合、クライアントは応答を履歴フォルダにキャッシュしません。したがって、ユーザーが [戻る] ボタンまたは [進む] ボタンをクリックした場合、クライアントはそのたびに新しい応答を要求します。この動作をオーバーライドするには、allow パラメータを true に設定して SetAllowResponseInBrowserHistory メソッドを呼び出します。
HttpCacheability が NoCache または ServerAndNoCache 以外の値に設定されている場合、SetAllowResponseInBrowserHistory メソッドを呼び出しても、allow の値に関係なく、効果はありません。

カスタムの HttpCachePolicy で SetAllowResponseInBrowserHistory メソッドをオーバーライドして、応答を履歴に格納するようクライアントに指示する方法を次のコード例に示します。
<%@ Page language="VB" AutoEventWireup="true" %> <HTML> <HEAD> <title>HttpCachePolicy - SetAllowResponseInBrowserHistory - Visual Basic .NET Example</title> <script runat="server"> Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) ' When HttpCacheability is set to NoCache or ServerAndNoCache ' the Expires HTTP header is set to -1 by default. This instructs ' the client to not cache responses in the History folder. Thus, ' each time you use the back/forward buttons, the client requests ' a new version of the response. HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache) ' Override the ServerAndNoCache behavior by setting the SetAllowInBrowserHistory ' method to true. This directs the client browser to store responses in ' its History folder. HttpContext.Current.Response.Cache.SetAllowResponseInBrowserHistory(True) ' Display the DateTime value. Label1.Text = DateTime.Now.ToLongTimeString() End Sub </script> </HEAD> <body> <form id="Form1" method="post" runat="server"> <h3>HttpCachePolicy - SetAllowResponseInBrowserHistory - Visual Basic .NET</h3> <P>Click the Submit button a few times, and then click the Browser's Back button.<BR> The page should be stored in the Browser's History folder</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 - SetAllowResponseInBrowserHistory - C# Example</title> <script runat="server"> void Page_Load(Object sender, EventArgs e) { // When HttpCacheability is set to NoCache or ServerAndNoCache // the Expires HTTP header is set to -1 by default. This instructs // the client to not cache responses in the History folder. Thus, // each time you use the back/forward buttons, the client requests // a new version of the response. HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache); // Override the ServerAndNoCache behavior by setting the SetAllowInBrowserHistory // method to true. This directs the client browser to store responses in // its History folder. HttpContext.Current.Response.Cache.SetAllowResponseInBrowserHistory(true); // Display the DateTime value. Label1.Text = DateTime.Now.ToLongTimeString(); } </script> </HEAD> <body> <form id="Form1" method="post" runat="server"> <h3>HttpCachePolicy - SetAllowResponseInBrowserHistory - C# Example</h3> <P>Click the Submit button a few times, and then click the Browser's Back button.<BR> The page should be stored in the Browser's History folder</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
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からHttpCachePolicy.SetAllowResponseInBrowserHistory メソッドを検索する場合は、下記のリンクをクリックしてください。

- HttpCachePolicy.SetAllowResponseInBrowserHistory メソッドのページへのリンク