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默认值为Full、、High``MediumLowMinimal。 集合的 TrustLevels 项分别指定安全级别名称和关联的策略文件。 可以通过提供映射到属性指定的 policyFile 文件自己的命名信任级别元素来扩展安全系统。 有关创建信任级别元素的信息,请参阅 trustLevel Element for securityPolicy (ASP.NET 设置 Schema)

适用于