title: Updating AppSettings via ASP.NET MVC Controller
body: <p>I'm writing a basic little forums web app (for fun and to sharpen the ole' saw), and I'm having a bit of trouble with AppSettings.</p>
  
  <p>My plan is to have these settings in their own file (Settings.config), to which I will grant modify permissions to the web process user account, and store all editable settings in this file (e.g. forum title, description, etc).</p>
  
  <p>This is my code:</p>
  
  <pre>
  [AcceptVerbs(HttpVerbs.Post)]
  public ActionResult Edit(FormCollection collection)
  {
      try
      {
          var config = WebConfigurationManager.OpenWebConfiguration("~/Web.config");
  
          config.AppSettings.Settings["SiteTitle"].Value = collection["SiteTitle"];
          config.AppSettings.Settings["SiteDescription"].Value = collection["SiteDescription"];
  
          config.Save(ConfigurationSaveMode.Minimal, false);
          ConfigurationManager.RefreshSection("appSettings");
  
          return RedirectToAction("Index");
      }
      catch (Exception ex)
      {
          ModelState.AddModelError("_FORM", ex.Message);
          return View("Index");
      }
  }
  </pre>
  
  <p>...but running it returns the following error:</p>
  
  <p><code>A configuration file cannot be created for the requested Configuration object.</code></p>
  
  <p>I've tried granting full permission to all users to the settings file, with no effect (I'm currently just running under Cassini, so the process user is me who has ownership of the file in any case).</p>
  
  <p>Any ideas?</p>