Question

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?

Was it helpful?

Solution

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();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top