<location> Element

Specifies the resource that specified configuration settings apply to.

<configuration>

   <location>

<location path="path" 
          allowOverride="true|false"/>

Optional Attributes

Attribute Option Description
path   The resource that the specified 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 specified to be false, configuration settings cannot be altered by Web.config files in child directories.
allowOverride   Specifies whether configuration settings can be overridden by configuration settings in Web.config files in child directories.
  true Specifies that configuration settings can be overridden. The default is true.
  false Specifies that configuration settings cannot be overridden.

Example

The following example allows an anonymous user to access the Logon.aspx page.

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

The following example sets the uploaded file size limit to 128KB for only the page specified.

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

The following example prevents configuration settings from being changed by Web.config files in child directories.

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

Requirements

Web Platform: IIS 5.0, IIS 5.1, IIS 6.0

Configuration File: Machine.config, Web.config

See Also

ASP.NET Configuration | ASP.NET Settings Schema