Encrypt Webconfig
protected void Encrypt_Click(object sender, EventArgs e)
{
Configuration mycon = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");
ConfigurationSection section = mycon.GetSection("connectionStrings");
if (!section.SectionInformation.IsProtected)
{
section.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
mycon.Save();
mycon.SaveAs("d:\\t.txt");
}
}
protected void Decrypt_Click(object sender, EventArgs e)
{
Configuration mycon = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");
ConfigurationSection section = mycon.GetSection("connectionStrings");
if (section.SectionInformation.IsProtected)
{
section.SectionInformation.UnprotectSection();
mycon.Save();
mycon.SaveAs("d:\\t1.txt");
}
}