SecurityPolicySection.TrustLevels Egenskap

Definition

Hämtar samlingen 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

Egenskapsvärde

En samling TrustLevels objekt.

Attribut

Exempel

Följande kodexempel visar hur du använder TrustLevels egenskapen, lägger till ett element på förtroendenivå i konfigurationsfilen och uppdaterar konfigurationsfilen. Det här kodexemplet är en del av ett större exempel för SecurityPolicySection klassen.

// 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"))

Kommentarer

Standardvärdena för egenskapen TrustLevels är Full, High, Medium, Lowoch Minimal. Objekten i TrustLevels samlingen anger var och en ett namn på säkerhetsnivå och en associerad principfil. Du kan utöka säkerhetssystemet genom att ange ett eget namngivet element på förtroendenivå som mappats till en fil som anges av policyFile attributet. Information om hur du skapar element på förtroendenivå finns i trustLevel Element for securityPolicy (ASP.NET Settings Schema).

Gäller för