This documentation is archived and is not being maintained.

SectionInformation.RequirePermission Property

Gets a value that indicates whether the associated configuration section requires access permissions.

Namespace: System.Configuration
Assembly: System.Configuration (in system.configuration.dll)

public bool RequirePermission { get; set; }
/** @property */
public boolean get_RequirePermission ()

/** @property */
public void set_RequirePermission (boolean value)

public function get RequirePermission () : boolean

public function set RequirePermission (value : boolean)

Not applicable.

Property Value

true if the requirePermission attribute is set to true; otherwise, false. The default is true.

Exception typeCondition

ConfigurationErrorsException

The selected value conflicts with a value that is already defined.

When RequirePermission is set to true, the GetSection methods are restricted by the trust level setting of the application. This means that methods or properties that allow access to configuration section handlers are restricted by the trust level set for the Web application.

NoteNote:

Because high and full trust are the only levels that allow access to files outside the current application domain, an application can use configuration section handlers only at these trust levels.

When RequirePermission is set to false, the access to the configuration data is not restricted by the application's trust level settings.

NoteNote:

The appropriate file ACL (Access Control List) permissions are still required, regardless of the RequirePermission setting. ACL permissions determine who can access the configuration file.

The following example shows two possible trust levels for a Web application when the RequirePermission property of the appSettings section is true.

<system.web>
   // With the following trust value 
   // the code below works.
  <trust level="Full" />
</system.web>

<system.web>
  // With the following trust value 
  // the code below does not work.
  <trust level="Medium" />
</system.web>

When the trust level is set to full, the following lines of code shown next work. Otherwise, they fail.

WebConfigurationManager.GetSection("appSettings");
WebConfigurationManager.AppSettings;

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

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0
Show: