title: Reading & Editing configuration inside Web.config
body: <p>I have a few settings that need to be edited from the admin panel of the site I'm currently working on. I thought it makes sense to place those settings inside the web.config (or should I place them somewhere else?). So anyway, I'm trying to write the necessary code to do this, but I got stuck... This is the first time I actually needed to do this so... :) Here's what I've got so far:</p>
  
  <p>appSettings section inside the Web.config:</p>
  
  <pre><code>  &lt;appSettings&gt;
      &lt;add key="ClientValidationEnabled" value="true" /&gt; 
      &lt;add key="UnobtrusiveJavaScriptEnabled" value="true" /&gt;
      &lt;add key="InvitationOnly" value="true" /&gt;
      &lt;add key="MaintainanceMode" value ="false"/&gt;
    &lt;/appSettings&gt;
  </code></pre>
  
  <p>And here's a class I'm trying to write to allow for easy retrieval and modification of some values that will be placed inside the appSettings section:</p>
  
  <pre><code>public static class SiteSettings
  {
      public static bool InvitationOnly
      {
          get
          {
              var invitation = WebConfigurationManager.AppSettings["InvitationOnly"];
              return Convert.ToBoolean(invitation);
          } 
          set
          {
              Configuration config = WebConfigurationManager.OpenWebConfiguration("~");
              var appSettings = config.GetSection("appSettings") as AppSettingsSection;
              if(appSettings != null)
              {
                  //got stuck here...
              }
          }
      }
  }
  </code></pre>
  
  <p>Am I on the right track? How do I continue from here?</p>
  
  <p>And by the way, how safe is it to place site settings inside the web.config? Should I be worried about anything?</p>
  
  <p>Thank you.</p>