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.
Yes you can have two web. config files in application. There are situations where your application is divided in to modules and for every module you need separate configuration. For example if you have a application which has two modules lets say accounts and sales.
A . config file contains XML that has a configuration element as the root node. Information inside this element is grouped into two main areas: the configuration section-handler declaration area, and the configuration section settings area.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With