为web.config文件的部分单独的配置文件 [英] Separate config file for sections of web.config

查看:104
本文介绍了为web.config文件的部分单独的配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能有web.config中的特定部分单独的配置文件?具体来说,我想移动IIS 7的重写部分出在web.config中和到它自己的配置文件。


解决方案

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


  

在一个单独的文件存储URL重写映射


 < system.webServer>
<&改写GT;
< rewriteMaps configSource =rewritemaps.config/>
<规则configSource =rewriteRules.config/>
< /重写>
< /system.webServer>

此外,您可以移动了不少配置部分,以便他们自己的文件:


  

&LT;的appSettings configSource =appSettings.config/&GT; <$c$c>[Docs]


  
  

&LT;是connectionStrings configSource =connectionStrings.config/&GT; <$c$c>[Docs]


  
  

&LT;页面configSource =pages.config/&GT; <$c$c>[Docs]


有关详细信息请参阅本页面,这将帮助您决定是否配置节可以存储在外部:


  

一般属性节元素继承


Is it possible to have separate config files for specific sections of the web.config? Specifically I'd like to move IIS 7's rewrite section out of the web.config and into it's own config file.

解决方案

You can certainly move your rewrite rules and mappings out to a separate file:

Storing URL rewrite mappings in a separate file

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

In addition you can move quite a few configuration sections to their own files:

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

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

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

For more info see this page which will help you decide if a configuration section can be stored externally:

General Attributes Inherited by Section Elements

这篇关于为web.config文件的部分单独的配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆