By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,275 Members | 920 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,275 IT Pros & Developers. It's quick & easy.

Is it possible to distribute web.config data into multiple files?

P: n/a
Hi,

Let us say my web.config is keep growing and I want to break the data
logically and still use web.config methods to retrieve the data.
e.g.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="Group Name">
<section name="Section name"> </section>
</sectionGroup>
</configSections>
<system.web>
</system.web>
</configuration>
Is it possible to keep the <sectionGroup name="Group Name"> or
<section name="Section name"> in seperate file?

Thanks In advance,
~SJ
Nov 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Dino,

what does your link about appSettings have to do with this? The question was
if it's possible to do includes in web.config, resulting in the file being
split into multiple config files...

Jerry

"Dino Chiesa [MSFT]" <di****@microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Yes, check this out:

http://msdn.microsoft.com/library/de...ngselement.asp
-Dino
<Microsoft/>

"Shrinivas" <sj**********@yahoo.com> wrote in message
news:ed**************************@posting.google.c om...
Hi,

Let us say my web.config is keep growing and I want to break the data
logically and still use web.config methods to retrieve the data.
e.g.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="Group Name">
<section name="Section name"> </section>
</sectionGroup>
</configSections>
<system.web>
</system.web>
</configuration>
Is it possible to keep the <sectionGroup name="Group Name"> or
<section name="Section name"> in seperate file?

Thanks In advance,
~SJ


Nov 17 '05 #2

P: n/a
Thanks for your reply.

But I was expected on sectionGroup not on appSettings

**********
<configsections>
<sectionGroup name="Group name">
<section name="Section name"> </section>
</sectiongroup>
</configsections>
*********

Thanks In Advance,
Shrinivas Joshi

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #3

P: n/a
Ok, now you're just changing your question. If you want to add your own
sections (but still keep everything in one web.config file) you just have to
declare those sections before you use them. Like this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="data"
type="System.Configuration.NameValueFileSectionHan dler, System,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>
<!-- Your regular web.config stuff -->
<data>
<add key="ConnectionString" value="Provider=SQLOLEDB; Data
Source=SqlServer;" />
</data>
</configuration>

and retrieve it like this:

((NameValueCollection)ConfigurationSettings.GetCon fig("data"))["ConnectionSt
ring"]

For some reason type="System.Configuration.NameValueFileSectionHan dler,
System" didn't work, I had to add version, culture and public key token to
the section definition. Also note that there are other section handlers too.

Jerry

"Shrinivas Joshi" <sj**********@yahoo.com> wrote in message
news:OP**************@TK2MSFTNGP09.phx.gbl...
Thanks for your reply.

But I was expected on sectionGroup not on appSettings

**********
<configsections>
<sectionGroup name="Group name">
<section name="Section name"> </section>
</sectiongroup>
</configsections>
*********

Thanks In Advance,
Shrinivas Joshi

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 17 '05 #4

P: n/a
I think the only way to do that right now is to write your own section
handler (possibly derived from SingleTagSectionHandler so you won't have to
write the code to read the include tag) that would include your other
configuration files.

Jerry

"Shrinivas Joshi" <sj**********@yahoo.com> wrote in message
news:OD**************@TK2MSFTNGP12.phx.gbl...
Jerry,

We were in the same page. I expected as you said
like "if it's possible to do includes in web.config, resulting in the
file being
split into multiple config files..."

Anyway, Thanks for your reply

Shrinivas

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.