Editare

Partajați prin


HttpCacheVaryByParams.Item[String] Property

Definition

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

Parameters

header
String

The name of the custom parameter.

Property Value

true if the cache should vary by the specified parameter value.

Exceptions

header is null.

Examples

The 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

Remarks

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.

When 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.

Applies to

See also