TrustSection Class [IIS 7 and higher]

Configures the level of code-access security that is applied to an application.

Syntax

class TrustSection : ConfigurationSection

Methods

The following table lists the methods exposed by the TrustSection class.

Name

Description

GetAllowDefinition

(Inherited from ConfigurationSection.)

GetAllowLocation

(Inherited from ConfigurationSection.)

RevertToParent

(Inherited from ConfigurationSection.)

SetAllowDefinition

(Inherited from ConfigurationSection.)

SetAllowLocation

(Inherited from ConfigurationSection.)

Properties

The following table lists the properties exposed by the TrustSection class.

Name

Description

Level

A required read/write string value that specifies the trust level under which the Web application will run. Each trust level is mapped to an individual XML policy file by using a TrustLevel configuration element. The policy file lists the set of permissions that are granted by each trust level. For more information about ASP.NET and policy files, see ASP.NET Trust Levels and Policy Files.

The Level property can contain a user-defined value if there is a matching security policy mapping defined in a TrustLevel element in the SecurityPolicySection class, or it can contain one of the possible values listed later in the Remarks section.

Location

(Inherited from ConfigurationSection.) A key property.

OriginUrl

An optional read/write string value that specifies a URL for use with the WebPermission permission that is granted in High and Medium trust. If present, this can be used for some permissions, such as WebRequest, that allow connectivity only to specific URLs that are specified by a WebPermission.

Path

(Inherited from ConfigurationSection.) A key property.

ProcessRequestInApplicationTrust

A read/write boolean value. true if page requests are automatically restricted to the permissions that are configured in the trust policy file that is applied to the ASP.NET application; otherwise, false. The default is true.

Trust policy files are specified in TrustLevel configuration elements in the SecurityPolicySection class. You can apply a single trust policy to an ASP.NET application by using the Level property.

NoteNote:
If the ProcessRequestInApplicationTrust property is set to false, ASP.NET requests can potentially execute under Full trust, even if the Level property specifies a different trust level. Unless there are specific reasons for doing this, do not reset this property from the default of true. This property is new in the .NET Framework 2.0.

SectionInformation

(Inherited from ConfigurationSection.)

Subclasses

This class contains no subclasses.

Remarks

The possible values for the Level property are listed in the following table. The default is Full (no restrictions).

Value

Description

Full

Specifies unrestricted permissions. Grants the ASP.NET application permissions to access any resource that is subject to operating system security. All privileged operations are supported. This setting is named Unrestricted in the System.Web.AspNetHostingPermissionLevel enumeration.

High

Specifies a high level of code access security, which means that the application cannot do any of the following things:

  • Call unmanaged code.

  • Call serviced components.

  • Write to the event log.

  • Access Microsoft Windows Message Queuing queues.

  • Access ODBC, OLE DB, or Oracle data sources.

Medium

Specifies a medium level of code access security, which means that, in addition to the restrictions for High, the ASP.NET application cannot do any of the following things:

  • Access files outside the application directory.

  • Access the registry.

Low

Specifies a low level of code access security, which means that, in addition to the restrictions for Medium, the application cannot do any of the following things:

Minimal

Specifies a minimal level of code access security, which means that the application has only execute permission.

Inheritance Hierarchy

ConfigurationSection

   TrustSection

Requirements

Type

Description

Client

Requires IIS 7 on Windows Vista.

Server

Requires IIS 7 on Windows Server 2008.

Product

IIS 7

MOF file

WebAdministration.mof

See Also

Reference

ConfigurationSection Class [IIS 7 and higher]

TrustLevel Class [IIS 7 and higher]

SystemWebSectionGroupTrust()()()()

TrustSection

Other Resources

System.Web.AspNetHostingPermissionLevel Enumeration

ASP.NET Trust Levels and Policy Files

System.Net.WebPermission Class

System.Net.WebRequest Class