HttpCachePolicy.SetVaryByCustom(String) 方法

定義

指定用來區分快取輸出回應的自訂文字字串。Specifies a custom text string to vary cached output responses by.

public:
 void SetVaryByCustom(System::String ^ custom);
public void SetVaryByCustom (string custom);
member this.SetVaryByCustom : string -> unit
Public Sub SetVaryByCustom (custom As String)

參數

custom
String

可以區分快取輸出的文字字串。The text string to vary cached output by.

例外狀況

customnullcustom is null.

已經呼叫過 SetVaryByCustom(String) 方法。The SetVaryByCustom(String) method has already been called.

範例

下列程式碼範例示範如何將自訂的變化字串設定為「接受字元集」,這會讓源伺服器的快取根據瀏覽器的標頭選擇數個快取回應的其中一個 Accept-CharsetThe following code example demonstrates how to set the custom vary string to "Accept-Charset", which causes the origin-server's cache to choose one of several cached responses depending on the browser's Accept-Charset header.

Response.Cache.SetVaryByCustom("Accept-Charset");

Response.Cache.SetVaryByCustom("Accept-Charset")
 

備註

SetVaryByCustom 在 .NET Framework 版本3.5 中引進。SetVaryByCustom is introduced in the .NET Framework version 3.5. 如需詳細資訊,請參閱版本和相依性For more information, see Versions and Dependencies.

適用於