HttpCacheVaryByParams.Item[String] 屬性

定義

取得或設定值,指出快取是否依據指定的 HTTP 要求參數有所不同。Gets or sets a value indicating whether the cache varies according to the specified HTTP request parameter.

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

自訂參數的名稱。The name of the custom parameter.

屬性值

Boolean

如果快取應該依指定的參數值有所不同,則為 truetrue if the cache should vary by the specified parameter value.

例外狀況

headernullheader is null.

範例

下列程式碼範例示範如何 Item[]HttpCachePolicy 與相關聯的物件存取索引子 HttpResponseThe following code example demonstrates how the Item[] indexer is accessed from the HttpCachePolicy object associated with an 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 如果在目前的參數集合中找到指定之參數的值,或如果集合設定為由 * (星號) (表示所有參數),則索引子會傳回。When used as an accessor (getter), the Item[] indexer returns true if a value for the specified parameter is found in the current parameters collection, or if the collection is set to vary by * (an asterisk), which indicates all parameters.

當做 (setter) 的轉變器使用時, Item[] 索引子會在參數集合中,將對應至指定標頭的參數值設定為 trueWhen used as a mutator (setter), the Item[] indexer sets the value for the parameter in the parameters collection that corresponds to the specified header to true. 您可以指定值 *,這表示所有參數。The value * can be specified, which indicates all parameters.

適用於