Topic
No replies
SystemAdmin
SystemAdmin
162 Posts
ACCEPTED ANSWER

Pinned topic ENCRYPT & DECRYPT WEC.CONFING SECTION

‏2008-07-19T12:14:20Z |
Hi,

This is the code for ENCRYPT & DECRYPT WEC.CONFING SECTION , Hope this will be usefull for all who will read this thread.

public void EncryptWebConfigurationSection(object sender, EventArgs e)
{
Configuration config = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
ConfigurationSection section = config.GetSection("appSettings");
if (!section.SectionInformation.IsProtected)
{
section.SectionInformation.ProtectSection("RsaProtectedConfigurationProvider");
config.Save();
}

}

/// http://www.infysolutions.com

public void DecryptWebConfigurationSection(object sender, EventArgs e)
{
Configuration config = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
ConfigurationSection section = config.GetSection("appSettings");
if (section.SectionInformation.IsProtected)
{
section.SectionInformation.UnprotectSection();
config.Save();
}
}

<hr />

Outsourcing Software Development