title: How I can change the applicationSettings in my web.config via C#
body: <p>I want to change the web.config via C#. </p>
  
  <p>My Web.config</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt;
  
      &lt;!--
        Weitere Informationen zum Konfigurieren der ASP.NET-Anwendung finden Sie unter
        "http://go.microsoft.com/fwlink/?LinkId=169433"
        --&gt;
  
      &lt;configuration&gt;
          &lt;configSections&gt;
              ...
          &lt;/configSections&gt;
          &lt;system.web&gt;
              ...
          &lt;/system.web&gt;
  
          &lt;applicationSettings&gt;
              &lt;AdminTest.Properties.Settings&gt;
                  &lt;setting name="AD_Admin" serializeAs="String"&gt;
                      &lt;value&gt;GastzugangAdmin&lt;/value&gt;
                  &lt;/setting&gt;
                  &lt;setting name="AD_User" serializeAs="String"&gt;
                      &lt;value&gt;GastzugangUser&lt;/value&gt;
                  &lt;/setting&gt;
              &lt;/AdminTest.Properties.Settings&gt;
          &lt;/applicationSettings&gt;
      &lt;/configuration&gt;
  </code></pre>
  
  <p>With string <code>ADAdmin = Properties.Settings.Default.AD_Admin;</code> can I get the value from th <code>web.config</code> but I don't know how I can overwrite this. I try this.</p>
  
  <pre><code>protected void btnCon_Click(object sender, EventArgs e)
          {
              string con = txtCon.Text;
  
              try
              {
                  ConfigurationManager.AppSettings.Set("AD_Admin", con);
                  Settings.Default.Save();
  
              }
              catch (Exception)
              {
  
              }
  
          }
  </code></pre>
  
  <p>But I doesn't work.</p>