配置可以通过使用 path 参数被设置成合适路径的 <location> 标记作用于特定资源。path 参数被用于对特定文件或子目录的识别来决定所使用的唯一配置,且参数中只能指定一个文件路径。path 参数也可以使用代表应用程序根目录的 "~/" 标识符。
比如,下例配置文件指定三个级别的配置:
-
作用于当前目录和所有子目录的配置(包含顶层 <configuration> 标记中的所有内容)。
-
作用于子目录 Sub1 的配置(包含
path参数被设置成 Sub1 的<location>标记中的所有内容)。 -
作用于子目录 Sub2 的配置(包含
path参数被设置成 Sub2 的<location>标记中的所有内容)。
<configuration>
<system.web>
<sessionState cookieless="true" timeout="10"/>
</system.web>
<!-- 子目录 "sub1" 的配置。 -->
<location path="sub1">
<system.web>
<httpHandlers>
<add verb="*" path="sub1" type="Type1"/>
<add verb="*" path="sub1" type="Type2"/>
</httpHandlers>
</system.web>
</location>
<!-- 子目录 "sub1/sub2" 的配置。 -->
<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>
浙公网安备 33010602011771号