共用方式為


HttpCacheVaryByParams 類別

定義

提供類型安全方式來設定 VaryByParams 屬性。

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

範例

下列程式代碼範例示範如何 HttpCacheVaryByParamsHttpCachePolicy 與 相關聯的 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 會識別當資源有多個快取回應時,ASP.NET 用來唯一識別回應變化的 HTTP GetPost 參數。 當回應相依於一組用戶端輸入時,例如標頭或參數時,這非常有用。

HttpCacheVaryByParams與 HTTP 快取控制標頭不直接相關,但有助於確保用戶端或 Proxy 會因指定的參數而有所不同。 如需 的詳細資訊 VaryByParams,請參閱 RFC 2616:超文本傳輸通訊協定 -- 可在萬維網聯盟 (W3C) 網站上 取得的 HTTP/1.1。 如需完整詳細數據,請參閱一節。

建構函式

名稱 Description
HttpCacheVaryByParams()

初始化 HttpCacheVaryByParams 類別的新執行個體。

屬性

名稱 Description
IgnoreParams

取得或設定值,指出 HTTP 回應是否依 GetPost 參數有所不同。

Item[String]

取得或設定值,指出快取是否依據指定的 HTTP 要求參數有所不同。

方法

名稱 Description
Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetParams()

取得值的陣列,這些值會指定要用來改變快取的 HTTP GETPOST 參數。

GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

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

設定值的陣列,這些值會指定要用來改變快取的 HTTP GETPOST 參數。

ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於

另請參閱