Include an XML file in web.config

D

Dominic

Suppose I have a web.config. I'd like to move some configuration
settings from this web.config and put it another XML file (say,
common.xml). Now, is there any way that I can modify the web.config
such that it will include (dynamically) the common.xml?

In other words, System.Configuration.ConfigurationSettings.GetConfig
can read settings in common.xml as they were in web.config.

Furthermore, when I load web.config into XML DOM object, the DOM
object will also contain the content in common.xml.

Thanks
Dominic
 
S

Steve C. Orr [MVP, MCSD]

I suspect about the best you could do is store a path in your web.config to
your XML file. Then you'll have to handle your XML file separately. You
could create a class that encapsulates all this though.
 
S

Sam-I-Am

Why not simply create a new configuration setions in web.config using
<configSections>

S
 
D

Dominic

Handling my common.xml and web.config separately is fine as long as
the ASP.NET can read the configuration settings in both common.xml and
web.config.

Now, my question is how to "store a path" in the web.config? Do you
mean that the web.config can somehow contain a path to the common.xml?
If this is the case, this is what I exactly need.

Thanks
 
D

Dominic

Thank you, Sam, for your reply, but new config section doesn't work in
my case.

Let me give you the reason why I would like to do this. I have a web
farm environment of N web servers. Some configuration settings in the
web.config are the same for each web server, but some of them are
different. Deploying a new web.config in this environment is a
headache because I can't simply copy the new web.config to all web
servers (since some configuration settings are server-specific)

In order to make the deployment easier, I come up with this idea. I
would like to use "common.xml" to store all the configuration settings
which are indpendent of the web server. All the server-specific
settings can be stored in the individual web.config. If there is any
change in those "common" settings, I can simply make the change in
common.xml, and copy the new common.xml to each server. This will make
the deployment simpler. However, the question is how the web.config
can "include" common.xml.

Dominic
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top