Answer 1)
public static void
mEncryptWebConfig(string appPath, string protectedSection, string
dataProtectionProvider) { System.Configuration.Configuration webConfig = WebConfigurationManager.OpenWebConfiguration(appPath); ConfigurationSection
webConfigSection = webConfig.GetSection(protectedSection);
if
(!webConfigSection.SectionInformation.IsProtected) { webConfigSection.SectionInformation.ProtectSection(dataProtectionProvider); webConfig.Save(); } }
public static void
mDecryptWebConfig(string appPath, string protectedSection) { System.Configuration.Configuration webConfig = WebConfigurationManager.OpenWebConfiguration(appPath); ConfigurationSection
webConfigSection = webConfig.GetSection(protectedSection);
if
(webConfigSection.SectionInformation.IsProtected) { webConfigSection.SectionInformation.UnprotectSection(); webConfig.Save(); } }
|