Updated: November 2007
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" />
The following sections describe attributes, child elements, and parent elements for this element.
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.
The location element can enclose other elements, either to apply configuration settings to a specific resource or to lock the configuration settings.
Element
configuration
Specifies the required root element in every configuration file that is used by the common language runtime and the .NET Framework applications.
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.
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"> <system.web> <httpRuntime maxRequestLength="128"/> </system.web> </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>
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