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
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.
You can have 1 Web. config file per folder . So in your root you can have a web. config and in a subfolder you can have another one that overrides settings from the one in the root.
For that question answer is Yes we can use multiple web. config files in single web application but how? By creating web. config file in sub root folders we can use multiple web.
Yes, you will be able to run an ASP.NET application without a WEB. CONFIG file in its root folder. If the application doesn't find a WEB. CONFIG file in its root folder, then it will take MACHINE.
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 :-( ).
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.
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