Web.config vs Machine.config

S

Sendamí Luque

Hello,
I would like to ask about how to use web.config file jointly how to use
machine.config.
I'm going to explain my problem: I'm working with BizTalk Server 2006, but
by means of web services. So, I have several web services and on each web
service there is a web.config document with its connection string defined.
At the same time, in the same server, in machine.config document I have the
same connection string defined. (It's needed for a BizTalk web service)
My question is if it exists some property or attribute in order to when one
web service with web.config use its connection string, and when the other web
service which use machine.config use its connection string. I mean, change
the hierarchies, depend on the web service, use the web.config which is under
the folder where the web service was created.
 
S

Scott Roberts

Sendamí Luque said:
Hello,
I would like to ask about how to use web.config file jointly how to use
machine.config.
I'm going to explain my problem: I'm working with BizTalk Server 2006, but
by means of web services. So, I have several web services and on each web
service there is a web.config document with its connection string defined.
At the same time, in the same server, in machine.config document I have
the
same connection string defined. (It's needed for a BizTalk web service)
My question is if it exists some property or attribute in order to when
one
web service with web.config use its connection string, and when the other
web
service which use machine.config use its connection string. I mean,
change
the hierarchies, depend on the web service, use the web.config which is
under
the folder where the web service was created.

Not sure I follow you 100%, but I can tell you that machine.config and
web.config are "merged" (in memory, not physically) by the
ConfigurationManager class. So the ConfigurationManager will load all
connection strings from machine.config *and* all connection strings from
web.config. You can access any connection string from either file the same
exact way. To test this, try putting a connection string in your web.config
with the same "name" as the connection string in your machine.config. You'll
get an error.

Now, having said that, it's fairly common for people to start off the
<connectionStrings> element of their web.config with a <clear/> tag. What
that does is effectively remove all previously loaded connection strings
(namely, those loaded from machine.config). If your web.config contains this
<clear/> tag then the connection strings defined in machine.config will be
unavailable.

Does that help at all, or are you simply trying to do something completely
different?
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top