This documentation is archived and is not being maintained.

TrustLevel Class

Defines the mapping of specific security levels to named policy files. This class cannot be inherited.

Namespace:  System.Web.Configuration
Assembly:  System.Web (in System.Web.dll)

public sealed class TrustLevel : ConfigurationElement

You can extend the security of your Web application by creating your own named TrustLevel object that is mapped to a file specified by the policyFile attribute.

The following code example demonstrates how to use the TrustLevel type.

#region Using directives

using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.Web;
using System.Web.Configuration;


namespace Samples.Aspnet.SystemWebConfiguration
  class UsingTrustLevel
    static void Main(string[] args)
        // Display title.
        Console.WriteLine("ASP.NET TrustLevel Info");

        // Instantiate a new TrustLevel object.
        TrustLevel TrustLevel1 =
          new TrustLevel("myLevel1", "myLevel1.config");

        // Get the Name of the TrustLevel object.
        Console.WriteLine("Name: {0}", TrustLevel1.Name);

        // Instantiate a new TrustLevel object.
        TrustLevel TrustLevel2 =
          new TrustLevel("myLevel2", "myLevel2.config");

        // Get the PolicyFile of the TrustLevel object.
        Console.WriteLine("PolicyFile: {0}", TrustLevel2.PolicyFile);

      catch (Exception e)
        // Unknown error.

      // Display and wait.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0