Configuration config = WebConfigurationManager.OpenWebConfiguration("/"); ConfigurationSection appSettings = config.GetSection("appSettings"); if (appSettings.SectionInformation.IsProtected) { appSettings.SectionInformation.UnprotectSection(); } else { appSettings.SectionInformation.ProtectSection( "DataProtectionConfigurationProvider"); } config.Save();
原文:http://www.cnblogs.com/honghong75042/p/3875012.html