次の方法で共有


HttpCacheVaryByParams.Item プロパティ

指定した HTTP 要求パラメータでキャッシュを識別するかどうかを示す値を取得または設定します。

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

構文

'宣言
Public Default Property Item ( _
    header As String _
) As Boolean
'使用
Dim instance As HttpCacheVaryByParams
Dim header As String
Dim value As Boolean

value = instance(header)

instance(header) = value
public bool this [
    string header
] { get; set; }
public:
property bool default [String^] {
    bool get (String^ header);
    void set (String^ header, bool value);
}
/** @property */
public boolean get_Item (String header)

/** @property */
public void set_Item (String header, boolean value)
適用できません。

パラメータ

  • header
    カスタム パラメータの名前。

プロパティ値

指定したパラメータ値でキャッシュを識別する場合は true

例外

例外の種類 条件

ArgumentNullException

header が null 参照 (Visual Basic では Nothing) です。

解説

アクセサ (取得側) として使用する場合、Item インデクサは、指定したパラメータの値が現在のパラメータ コレクションで見つかった場合、またはコレクションの識別に使用するパラメータとして * (アスタリスク) が設定され、すべてのパラメータを使用する場合に、true を返します。

ミューテータ (設定側) として使用する場合、Item インデクサは、指定したヘッダーに対応するパラメータ コレクションに含まれているパラメータの値を true に設定します。値として * が指定される場合があります。これは、全パラメータを意味します。

使用例

Item インデクサに、HttpResponse に関連付けられている HttpCachePolicy オブジェクトからアクセスする方法を次のコード例に示します。

Response.Cache.SetExpires(DateTime.Now.AddSeconds(60))
Response.Cache.SetCacheability(HttpCacheability.Public)
Response.Cache.SetValidUntilExpires(False)
Response.Cache.VaryByParams("Category") = True

If Response.Cache.VaryByParams("Category") Then
   '...
End If
 
Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
Response.Cache.SetCacheability(HttpCacheability.Public);
Response.Cache.SetValidUntilExpires(false);
Response.Cache.VaryByParams["Category"] = true;

if (Response.Cache.VaryByParams["Category"])
{
   //...
}
get_Response().get_Cache().SetExpires(DateTime.get_Now().
    AddSeconds(60));
get_Response().get_Cache().SetCacheability(HttpCacheability.Public);
get_Response().get_Cache().SetValidUntilExpires(false);
get_Response().get_Cache().get_VaryByParams().
    set_Item("Category", true);

if (get_Response().get_Cache().get_VaryByParams().
    get_Item("Category")) {
    //...
}
Response.Cache.SetExpires(DateTime.Now.AddSeconds(60))
Response.Cache.SetCacheability(HttpCacheability.Public)
Response.Cache.SetValidUntilExpires(false)
Response.Cache.VaryByParams("Category") = true

if(Response.Cache.VaryByParams("Category")){
   //...
}
 

プラットフォーム

Windows 98,Windows Server 2000 SP4,Windows CE,Windows Millennium Edition,Windows Mobile for Pocket PC,Windows Mobile for Smartphone,Windows Server 2003,Windows XP Media Center Edition,Windows XP Professional x64 Edition,Windows XP SP2,Windows XP Starter Edition

Microsoft .NET Framework 3.0 は Windows Vista,Microsoft Windows XP SP2,および Windows Server 2003 SP1 でサポートされています。

バージョン情報

.NET Framework

サポート対象 : 3.0,2.0,1.1,1.0

参照

関連項目

HttpCacheVaryByParams クラス
HttpCacheVaryByParams メンバ
System.Web 名前空間

その他の技術情報

方法 : パラメータを使用してページのバージョンをキャッシュする
ページの複数バージョンのキャッシュ