Freigeben über


Configuring Specific Files and Subdirectories

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. Only one file path can be used in the path attribute. For more information, see ASP.NET Web Project Paths.

For example, the following example 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" type="Type1"/>
        <add verb="*" path="sub1" type="Type2"/>
      </httpHandlers>
    </system.web>
  </location>
   
  <!-- Configuration for the "sub1/sub2" subdirectory. -->
  <location path="sub1/sub2">
    <system.web>
      <httpHandlers>
        <add verb="*" path="sub1/sub2" type="Type3"/>
        <add verb="*" path="sub1/sub2" type="Type4"/>
      </httpHandlers>
    </system.web>
  </location>
</configuration>

See Also

Tasks

How to: Configure Specific Directories Using Location Settings

Other Resources

ASP.NET Web Site Administration

Configuring .NET Framework Apps