title: Check setting exists in web.config
body: <p>How do I check a setting exists in the web.config file?</p>
  
  <p>I found the following code, however i think it is aimed at an app.config file? where as my settings are in web.config. The below code returns no keys even though there are 6.</p>
  
  <pre><code> if (ConfigurationManager.AppSettings.AllKeys.Contains(settingName))
   {
       return 1;
   }
   else
   {
        return 0;
   }
  </code></pre>
  
  <p>Example settings in <strong>web.config:</strong></p>
  
  <pre><code>&lt;configuration&gt;
    . . .
    &lt;applicationSettings&gt;
      &lt;ProjectNameSpace.Properties.Settings&gt;
      &lt;setting name="mySetting" serializeAs="String"&gt;
         &lt;value&gt;True&lt;/value&gt;
       &lt;/setting&gt;
     &lt;/ProjectNameSpace.Properties.Settings&gt;
    &lt;/applicationSettings&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Originally i was trying to read it out, and check if it errors or exists.</p>
  
  <pre><code> var property = Properties.Settings.Default.Properties[settingName];
  </code></pre>
  
  <p>But that line of code seems to load from the web.config, and if it doesn't exist, it gets it from the project settings. So I cant tell if it is in the web.config or not by checking the value is blank, as it is set to something else!</p>