简体   繁体   中英

divide web.config

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

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

You can only put the configSource= on a configuration section - eg

<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 :-( ).

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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