共用方式為


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

屬性值

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 指定檔案的專屬具名信任層級專案來擴充安全性系統。 如需建立信任層級專案的詳細資訊,請參閱securityPolicy 的 trustLevel 元素 (ASP.NET 設定架構)

適用於