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.

适用于