共用方式為


組態 <location> 設定

您可使用 <location> 標記加上適當的 path 屬性,將組態設定套用至特定資源。path 屬性可用來識別套用唯一組態設定的特定檔案或子目錄。

例如,下列組態檔指定三種層級的設定:

  • 套用至目前目錄和所有子目錄的設定 (最上層的 <configuration> 標記包含的所有內容)。
  • 套用至 Sub1 子目錄的設定 (<location> 標記包含的所有內容,其路徑屬性設定為 Sub1)。
  • 套用至 Sub2 子目錄的設定 (<location> 標記包含的所有內容,其路徑屬性設定為 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>

請參閱

ASP.NET 組態 | 設定應用程式