1

I have searched all over and I can't seem to get this one solved.

All I am trying to do is read application settings from the web.config.

I found an article here - but that isn't working.

my code:

return System.Web.Configuration.WebConfigurationManager.AppSettings[settingName];

My Web Config does indeed have settings:

  <setting name="AirmetDataCacheExpiration" serializeAs="String">
    <value>5</value>
  </setting>
  <setting name="MetarDataCacheExpiration" serializeAs="String">
    <value>5</value>
  </setting>
  <setting name="TafDataCacheExpiration" serializeAs="String">
    <value>5</value>
  </setting>

My hunch is this is something to do with the web.config in my VS solution and the machine.config...

So how do I make sure I am reading the right one?

JDBennett
  • 1,323
  • 17
  • 45
  • does this help? http://stackoverflow.com/questions/2060993/differences-in-behavior-between-system-web-configuration-webconfigurationmanager – sambomartin Mar 16 '13 at 21:11
  • Just tried it. Now I get an error: Error 67 'System.Configuration.ConfigurationElement.this[System.Configuration.ConfigurationProperty]' is inaccessible due to its protection level – JDBennett Mar 16 '13 at 21:25
  • I've always used `System.Configuration.ConfigurationManager.AppSettings[name]` to access appsettings in web.config. have you tried that? – sambomartin Mar 16 '13 at 21:29
  • That's what I had originally. I just tried again - no luck. It's got me stumped. – JDBennett Mar 16 '13 at 21:34

1 Answers1

0

Found the answer. This link helped steer me on the right path.

So instead of using System.Configuration.ConfigurationManager["appsetting"]

You use this:

(string)Properties.Settings.Default[settingName].ToString();
Community
  • 1
  • 1
JDBennett
  • 1,323
  • 17
  • 45