次の方法で共有


location Element (ASP.NET Settings Schema) 

Specifies the resource that child configuration settings apply to and locks configuration settings, preventing the settings from being overridden by child configuration files.

This element is new in the .NET Framework version 2.0.

<location 
      allowOverride="True|False"
   path="path" 
/>

Attributes and Elements

The following sections describe attributes, child elements, and parent elements for this element.

Attributes

Attribute Description

allowOverride

Optional Boolean attribute.

Specifies whether configuration settings can be overridden by configuration settings that are in Web.config files that are in child directories.

The default is True.

path

Optional String attribute.

Specifies the resource that the contained configuration settings apply to. Using location with a missing path attribute applies the configuration settings to the current directory and all child directories. If location is used with no path attribute and allowOverride is False, configuration settings cannot be altered by Web.config files that are in child directories.

Child Elements

The location element can enclose other elements, either to apply configuration settings to a specific resource or to lock the configuration settings.

Parent Elements

Element Description

configuration

Specifies the required root element in every configuration file that is used by the common language runtime and the .NET Framework applications.

Remarks

The location element specifies the resource that child configuration settings apply to and is also used to lock configuration settings, preventing the settings from being overridden by child configuration files.

The location element can enclose other elements, either to apply configuration settings to a specific resource or to lock the settings. For more information, see Configuring Specific Files and Subdirectories and Locking Configuration Settings.

Example

The following code example demonstrates how to allow an anonymous user to gain access the Logon.aspx page.

<configuration>
   <location path="Logon.aspx">
      <system.web>
         <authorization>
            <allow users="?"/>
         </authorization>
      </system.web>
   </location>
</configuration>

The following code example demonstrates how to set the uploaded file size limit to 128 KB for only the page specified.

<configuration>
   <location path="UploadPage.aspx">
      <httpRuntime maxRequestLength="128"/>
   </location>
</configuration>

The following code example demonstrates how to prevent configuration settings from being changed by Web.config files that are in child directories.

<configuration>
   <location allowOverride="false"/>
</configuration>

Element Information

Configuration section handler

Does not apply.

Configuration member

ConfigurationLocation

Configurable locations

Machine.config

Root-level Web.config

Application-level Web.config

Virtual or physical directory–level Web.config

Requirements

Microsoft Internet Information Services (IIS) version 5.0, 5.1, or 6.0

The .NET Framework version 2.0

Microsoft Visual Studio 2003 or Visual Studio 2005

See Also

Tasks

How to: Lock ASP.NET Configuration Settings
How to: Configure Specific Directories Using Location Settings

Reference

configuration Element (General Settings Schema)
ConfigurationLocation

Concepts

ASP.NET Configuration Overview
Securing ASP.NET Configuration
Locking Configuration Settings
Configuring Specific Files and Subdirectories

Other Resources

ASP.NET Configuration Settings