繁体   English   中英

为web.config的各个部分分隔配置文件

[英]Separate config file for sections of web.config

是否可以为web.config的特定部分分别配置文件? 具体来说,我想将IIS 7的重写部分移出web.config并进入它自己的配置文件。

您当然可以将重写规则和映射移到单独的文件中:

将URL重写映射存储在单独的文件中

<system.webServer>
  <rewrite>
    <rewriteMaps configSource="rewritemaps.config" />
    <rules configSource="rewriteRules.config" />
  </rewrite>
</system.webServer>

此外,您可以将相当多的配置部分移动到自己的文件中:

<appSettings configSource="appSettings.config" /> [Docs]

<connectionStrings configSource="connectionStrings.config"/> [Docs]

<pages configSource="pages.config"/> [Docs]

有关详细信息,请参阅此页面,该页面将帮助您确定是否可以在外部存储配置部分:

由Section Elements继承的常规属性

是的,这是可能的。

对于每个配置部分,您可以将configSource属性设置为您保存配置的位置(文件)。

例如:

<appSettings configSource="appSettings.config" />

appSettings.config中

<?xml version="1.0" encoding="UTF-8"?>
<appSettings>
    <add key="myKey" value="myValue" />
</appSettings>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM