修改Web.Config里的值

public void Modify(string key, string value)

{

Configuration configuration = WebConfigurationManager.OpenWebConfiguration("~");

AppSettingsSection appSettingsSection = (AppSettingsSection)configuration.GetSection("appSettings");

   if (appSettingsSection != null)

   {

       appSettingsSection.Settings[key].Value = value;

       config.Save();

   }

}

原文地址:https://www.cnblogs.com/binaryworms/p/1718014.html