HttpCachePolicy.SetAllowResponseInBrowserHistory メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > HttpCachePolicy.SetAllowResponseInBrowserHistory メソッドの意味・解説 

HttpCachePolicy.SetAllowResponseInBrowserHistory メソッド

allow パラメータtrue場合サーバーの HttpCacheability の設定に関係なく、クライアント ブラウザ履歴キャッシュ応答格納できるようにします。

名前空間: System.Web
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public Sub SetAllowResponseInBrowserHistory
 ( _
    allow As Boolean _
)
Dim instance As HttpCachePolicy
Dim allow As Boolean

instance.SetAllowResponseInBrowserHistory(allow)
public void SetAllowResponseInBrowserHistory
 (
    bool allow
)
public:
void SetAllowResponseInBrowserHistory (
    bool allow
)
public void SetAllowResponseInBrowserHistory
 (
    boolean allow
)
public function SetAllowResponseInBrowserHistory
 (
    allow : boolean
)

パラメータ

allow

応答履歴フォルダ格納するようクライアントブラウザ指示する場合trueそれ以外場合false既定値false です。

解説解説

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

HttpCacheabilityNoCache または 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>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からHttpCachePolicy.SetAllowResponseInBrowserHistory メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からHttpCachePolicy.SetAllowResponseInBrowserHistory メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からHttpCachePolicy.SetAllowResponseInBrowserHistory メソッド を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

HttpCachePolicy.SetAllowResponseInBrowserHistory メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



HttpCachePolicy.SetAllowResponseInBrowserHistory メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS