Share via


Configuration <location> Settings in ASP.NET

Applies To: Windows Server 2003, Windows Server 2003 R2, Windows Server 2003 with SP1

Configuration settings can be applied to specific resources by using a <location> tag with an appropriate path attribute. The path attribute can be used to identify a specific file or child directory to which unique configuration settings apply.

For example, the following configuration file specifies settings at three levels:

  • Settings that apply to the current directory and all child directories (everything contained within the top <configuration> tag).

  • Settings that apply to the Sub1 child directory (everything contained within the <location> tag with a path attribute set to Sub1).

  • Settings that apply to the Sub2 child directory (everything contained within the <location> tag with a path attribute set to Sub2).

<configuration>

<system.web>

<sessionState cookieless="true" timeout="10"/>

</system.web>

<!-- Configuration for the "Sub1" subdirectory. -->

<location path="sub1">

<system.web>

<httpHandlers>

<add verb="*" path="Sub1.Scott" type="Sub1.Scott"/>

<add verb="*" path="Sub1.David" type="Sub1.David"/>

</httpHandlers>

</system.web>

</location>

<!-- Configuration for the "Sub2" subdirectory. -->

<location path="sub2">

<system.web>

<httpHandlers>

<add verb="*" path="Sub2.Scott" type="Sub2.Scott"/>

<add verb="*" path="Sub2.David" type="Sub2.David"/>

</httpHandlers>

</system.web>

</location>

</configuration>

Hierarchical Configuration Architecture in ASP.NET