N
Nick Gilbert
Hi,
I would like the ability to store the configuration settings for all
versions of my site in a single web.config file by using different
sections. Eg:
<siteConfig>
<machine name="XENON">
<site url="/blog/">
<mode value="live">
<add key="ConnectionString" value="blah" />
<add key="WebmasterEmail" value="(e-mail address removed)" />
</mode>
<mode value="dev">
<add key="ConnectionString" value="blah" />
<add key="WebmasterEmail" value="(e-mail address removed)" />
</mode>
</site>
<site url="/intranet/">
<mode value="live">
<add key="ConnectionString" value="blah2" />
<add key="WebmasterEmail" value="(e-mail address removed)" />
</mode>
<mode value="dev">
<add key="ConnectionString" value="blah2" />
<add key="WebmasterEmail" value="(e-mail address removed)" />
</mode>
</site>
</machine>
<machine name="NEON">
...(variation on above)
</machine>
</siteConfig>
How can I write a configuration section handler that will allow me to do
this? There are some examples on the web but most of them don't have any
attributes on the custom section names, so I'm not sure it's possible to
do what I want.
If it's possible to retrieve the values somehow using the structure
above, then it will be simple for me to write the code that accesses the
correct nodes based on things like Server.MachineName and Request.Url etc.
If anyone has seen any code which might help me, please let me know.
Thanks,
Nick...
I would like the ability to store the configuration settings for all
versions of my site in a single web.config file by using different
sections. Eg:
<siteConfig>
<machine name="XENON">
<site url="/blog/">
<mode value="live">
<add key="ConnectionString" value="blah" />
<add key="WebmasterEmail" value="(e-mail address removed)" />
</mode>
<mode value="dev">
<add key="ConnectionString" value="blah" />
<add key="WebmasterEmail" value="(e-mail address removed)" />
</mode>
</site>
<site url="/intranet/">
<mode value="live">
<add key="ConnectionString" value="blah2" />
<add key="WebmasterEmail" value="(e-mail address removed)" />
</mode>
<mode value="dev">
<add key="ConnectionString" value="blah2" />
<add key="WebmasterEmail" value="(e-mail address removed)" />
</mode>
</site>
</machine>
<machine name="NEON">
...(variation on above)
</machine>
</siteConfig>
How can I write a configuration section handler that will allow me to do
this? There are some examples on the web but most of them don't have any
attributes on the custom section names, so I'm not sure it's possible to
do what I want.
If it's possible to retrieve the values somehow using the structure
above, then it will be simple for me to write the code that accesses the
correct nodes based on things like Server.MachineName and Request.Url etc.
If anyone has seen any code which might help me, please let me know.
Thanks,
Nick...