I have my appSettings
defined in a separate config file called Appsettings.Dev.Config
, and I include that file inside my web.config
file like so
<appSettings configSource="ConfigFiles\AppSettings.Dev.config"/>
Lets say one of the settings in the file is
<add key="MailerEmailAccount" value="myemail@myserver.com" />
Can I access the value of the setting MailerEmailAccount
elsewhere inside web.config? How?
Nope, the web configuration file cannot pull "settings" from itself; it's not dynamic at all. The only sort of dynamic functionality is the ability to include other .config, but that's just a "suck all these settings in as if they were part of me" kind of thing.
It might be possible if you create a custom
ConfigurationSection
that pulls the value fromappSettings
.Here's an article that explain how to create a custom configuration section:
http://haacked.com/archive/2007/03/12/custom-configuration-sections-in-3-easy-steps.aspx
I don't know if this is what you're looking for, but it's the only way I can think of to read a
web.config
setting from within theweb.config
.EDIT
I haven't tested this, but maybe something like this would work?: