Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Separate config file for sections of web.config

Tags:

asp.net

iis-7

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.

like image 309
CodeMonkey1313 Avatar asked Dec 17 '10 13:12

CodeMonkey1313


People also ask

Can we have two Web config files for a Web application?

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.

What are the different sections in a Web config file?

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.


1 Answers

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

like image 58
Kev Avatar answered Sep 22 '22 10:09

Kev