views:

190

answers:

2

I am developing a asp.net project and I dont have very long web.config file yet(more then 400 lines). but with this nhibernate log4net and urlrewrites. its getting bigger and bigger. is there a proper way to divide web.config into pieces. like nhibernate.config and log4net.config ofcourse urlrewrite.config

thanks in advance

+1  A: 

This is possible by using the configSource attribute of root sections in the config file. This is actually a feature of the .NET configuration system so it can be done in any web or app config file.

Here is a blog post that describes this feature quite well.

joshperry
I just tried that for system.webserver tag. it includes the urlrewrite mostly. and now I am getting "Unrecognized attribute 'configSource'"
özkan pakdil
Yes, that is a problem. system.webServer is not a standard config section itself. You should be able to use configSource on any of it's child elements however.
joshperry
+1  A: 

system.webServer is a configuration section group - you cannot externalize that.

You can only put the configSource= on a configuration section - e.g.

<system.webServer>
    <validation configSource="validation.config"/>
    <modules configSource="modules.config" />
    <handlers configSource="handlers.config" />
</system.webServer>

What is a configuration section group or a regular configuration section can only be determined by looking at the documentation for those things (and even then it's often not very easy to figure out whether it's a section or a section group :-( ).

marc_s