Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

SecurityPolicySection.TrustLevels Property

Gets the TrustLevels collection.

Namespace:  System.Web.Configuration
Assembly:  System.Web (in System.Web.dll)
[ConfigurationPropertyAttribute("", IsDefaultCollection = true)]
public TrustLevelCollection TrustLevels { get; }

Property Value

Type: System.Web.Configuration.TrustLevelCollection
A collection of TrustLevels objects.

The default values for the TrustLevels property are Full, High, Medium, Low, and Minimal. The items of the TrustLevels collection each specify a security-level name and an associated policy file. You can extend the security system by providing your own named trust-level element mapped to a file specified by the policyFile attribute. For information about creating trust-level elements, see trustLevel Element for securityPolicy (ASP.NET Settings Schema).

The following code example demonstrates how to use the TrustLevels property, add a trust-level element to the configuration file, and update the configuration file. This code example is part of a larger example provided for the SecurityPolicySection class.


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


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.