Step-1 -Run VS as administrator
protected void btn_encriptConfig_Click(object sender, EventArgs e)
{
Encryption(true);
}
protected void Encryption(bool EncryptoValue)
{
Configuration config =WebConfigurationManager.OpenWebConfiguration("~");
ConfigurationSection sec = config.GetSection("connectionStrings");
if (EncryptoValue == true)
{
sec.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
}
else
{
sec.SectionInformation.UnprotectSection();
}
config.Save();
}
protected void btn_encriptConfig_Click(object sender, EventArgs e)
{
Encryption(true);
}
protected void Encryption(bool EncryptoValue)
{
Configuration config =WebConfigurationManager.OpenWebConfiguration("~");
ConfigurationSection sec = config.GetSection("connectionStrings");
if (EncryptoValue == true)
{
sec.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
}
else
{
sec.SectionInformation.UnprotectSection();
}
config.Save();
}