HttpCacheVaryByParams 類別

定義

提供類型安全方式來設定 VaryByParams 屬性。Provides a type-safe way to set the VaryByParams property.

public ref class HttpCacheVaryByParams sealed
public sealed class HttpCacheVaryByParams
type HttpCacheVaryByParams = class
Public NotInheritable Class HttpCacheVaryByParams
繼承
HttpCacheVaryByParams

範例

下列程式碼範例示範如何 HttpCacheVaryByParamsHttpCachePolicy 與相關聯的物件存取物件 HttpResponseThe following code example demonstrates how the HttpCacheVaryByParams object 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
 

備註

VaryByParams Get Post 當資源有多個快取回應時,屬性會識別 ASP.NET 用來唯一識別回應變化的 HTTP 或參數。The VaryByParams property identifies which HTTP Get or Post parameters ASP.NET uses to uniquely identify a variation of the response when there are multiple cached responses for a resource. 當回應相依于一組用戶端輸入,例如標頭或參數時,這會很有用。This is useful when a response depends on a set of client inputs, such as headers or parameters.

HttpCacheVaryByParams HTTP 快取控制標頭不直接相關,但可協助確保用戶端或 proxy 依指定的參數而有所不同。The HttpCacheVaryByParams is not directly related to HTTP cache-control headers, but helps ensure that a client or proxy varies by the specified parameters. 如需的詳細資訊 VaryByParams ,請參閱 全球資訊網協會 (W3C) 網站 上提供的 RFC 2616:超文字傳輸通訊協定--HTTP/1.1。For more information about VaryByParams, see RFC 2616: Hypertext Transfer Protocol -- HTTP/1.1, available on the World Wide Web Consortium (W3C) Web site. 如需完整的詳細資訊,請參閱第14節:「標頭欄位定義」。See section 14, "Header Field Definitions", for complete details.

建構函式

HttpCacheVaryByParams()

初始化 HttpCacheVaryByParams 類別的新執行個體。Initializes a new instance of the HttpCacheVaryByParams class.

屬性

IgnoreParams

取得或設定值,指出 HTTP 回應是否依 GetPost 參數有所不同。Gets or sets a value indicating whether an HTTP response varies by Get or Post parameters.

Item[String]

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

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetParams()

取得值的陣列,這些值會指定要用來改變快取的 HTTP GETPOST 參數。Gets an array of values which specify the HTTP GET or POST parameters to be used for varying the cache.

GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
SetParams(String[])

設定值的陣列,這些值會指定要用來改變快取的 HTTP GETPOST 參數。Sets an array of values which specify the HTTP GET or POST parameters to be used for varying the cache.

ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

適用於

另請參閱