共用方式為


SecurityPolicySection.TrustLevels 屬性

定義

拿到 TrustLevels 收藏。

public:
 property System::Web::Configuration::TrustLevelCollection ^ TrustLevels { System::Web::Configuration::TrustLevelCollection ^ get(); };
[System.Configuration.ConfigurationProperty("", IsDefaultCollection=true)]
public System.Web.Configuration.TrustLevelCollection TrustLevels { get; }
[<System.Configuration.ConfigurationProperty("", IsDefaultCollection=true)>]
member this.TrustLevels : System.Web.Configuration.TrustLevelCollection
Public ReadOnly Property TrustLevels As TrustLevelCollection

屬性值

物件的 TrustLevels 集合。

屬性

範例

以下程式碼範例示範如何使用該 TrustLevels 屬性、在設定檔中加入信任層級元素,以及更新設定檔。 此程式碼範例是本類別更大範例 SecurityPolicySection 的一部分。

// Display elements of the TrustLevels collection property.
for (int i = 0; i < configSection.TrustLevels.Count; i++) 
{
  Console.WriteLine();
  Console.WriteLine("TrustLevel {0}:", i);
  Console.WriteLine("Name: {0}", 
    configSection.TrustLevels.Get(i).Name);
  Console.WriteLine("Type: {0}", 
    configSection.TrustLevels.Get(i).PolicyFile);
}

// Add a TrustLevel element to the configuration file.
configSection.TrustLevels.Add(new TrustLevel("myTrust", "mytrust.config"));
' Display elements of the TrustLevels collection property.
For i As Integer = 0 To (configSection.TrustLevels.Count - 1)
  Console.WriteLine()
  Console.WriteLine("TrustLevel {0}:", i)
  Console.WriteLine("Name: {0}", _
   configSection.TrustLevels.Get(i).Name)
  Console.WriteLine("Type: {0}", _
   configSection.TrustLevels.Get(i).PolicyFile)
Next i

' Add a TrustLevel element to the configuration file.
configSection.TrustLevels.Add(New TrustLevel("myTrust", "mytrust.config"))

備註

屬性的TrustLevels預設值為 FullHighMediumLowMinimal、 和 。 集合中的 TrustLevels 項目各自指定一個安全層級名稱及對應的政策檔案。 你可以透過提供自己命名的信任層級元素,並映射到屬性指定的 policyFile 檔案來擴充安全系統。 關於建立信任層級元素的資訊,請參見 trustLevel 元素以取得安全政策(ASP.NET 設定架構)。

適用於