protected void Button1_Click(object sender, EventArgs e) { Configuration config = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath); ConfigurationSection appSettings = config.GetSection("connectionStrings"); if (appSettings.SectionInformation.IsProtected) { appSettings.SectionInformation.UnprotectSection(); lblInfo.Text = "配置节已解密!"; } else { appSettings.SectionInformation.ProtectSection( "DataProtectionConfigurationProvider"); Button1.Text = "解密"; lblInfo.Text = "已加密配置节!"; } config.Save(); }