HttpCacheVaryByParams.Item[String] 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定一個值,表示快取是否會依照指定的 HTTP 請求參數而變化。
public:
property bool default[System::String ^] { bool get(System::String ^ header); void set(System::String ^ header, bool value); };
public bool this[string header] { get; set; }
member this.Item(string) : bool with get, set
Default Public Property Item(header As String) As Boolean
參數
- header
- String
自訂參數的名稱。
屬性值
true 快取值是否應該隨指定的參數值變化。
例外狀況
header 是 null。
範例
以下程式碼範例說明如何 Item[] 從 HttpCachePolicy 與 相關 HttpResponse聯的物件存取索引器。
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"])
{
//...
}
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
備註
當作為存取器(getter)使用時, Item[] 索引器會回傳 true 該參數的值,若在當前參數集合中找到,或集合設定為變化 *(星號),表示所有參數。
當用作變異器(設定器)時, Item[] 索引器會將參數集合中對應指定標頭的參數值設定為 true。 可以指定值 * 來表示所有參數。