HttpCacheVaryByParams.Item[String] 属性

定义

获取或设置一个值,该值指示缓存是否因指定的 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

自定义参数的名称。

属性值

如果缓存应因指定的参数值而异,则为

例外

headernull

示例

下面的代码示例演示如何 /> 关联的对象访问索引器。

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 该索引器,该值指示所有参数。

用作 mutator (setter)时, Item[] 索引器将参数集合中与指定标头对应的参数的值设置为 true。 可以指定值 * ,该值指示所有参数。

适用于

另请参阅