Share via


OutputCacheProfileCollection.Add(OutputCacheProfile) 方法

定義

OutputCacheProfile 物件加入至集合。

public:
 void Add(System::Web::Configuration::OutputCacheProfile ^ name);
public void Add (System.Web.Configuration.OutputCacheProfile name);
member this.Add : System.Web.Configuration.OutputCacheProfile -> unit
Public Sub Add (name As OutputCacheProfile)

參數

name
OutputCacheProfile

要加入集合的 OutputCacheProfile 物件的名稱。

例外狀況

OutputCacheProfile 物件已經存在於集合中,或者集合是唯讀的。

範例

下列程式碼範例示範如何使用 Add 方法。

// Execute the Add method.
System.Web.Configuration.OutputCacheProfile outputCacheProfile0 =
  new System.Web.Configuration.OutputCacheProfile("MyCacheProfile");
outputCacheProfile0.Location = 
    System.Web.UI.OutputCacheLocation.Any;
outputCacheProfile0.NoStore = false;

outputCacheProfiles.Add(outputCacheProfile0);

// Update if not locked.
if (!outputCacheSettings.IsReadOnly())
{
    webConfig.Save();
}
' Execute the Add method.
  Dim outputCacheProfile0 _
  As New System.Web.Configuration.OutputCacheProfile( _
  "MyCacheProfile")
  outputCacheProfile0.Location = _
  System.Web.UI.OutputCacheLocation.Any
  outputCacheProfile0.NoStore = _
  False

  outputCacheProfiles.Add(outputCacheProfile0)

' Update if not locked.
  If Not outputCacheSettings.IsReadOnly() Then
      webConfig.Save()
  End If

備註

集合不能包含 OutputCacheProfile 具有相同名稱的物件。

適用於

另請參閱