Decrypt connectionString in web.config?

I am encrypting my connection string in the web.config file with this code in my aspx download.

protected void Page_Load(object sender, EventArgs e) { Configuration config = WebConfigurationManager.OpenWebConfiguration("~"); ConnectionStringsSection connSection = (ConnectionStringsSection)config.GetSection("connectionStrings"); connSection.SectionInformation.ProtectSection("DataProtectionConfigurationProvider"); config.Save(); } 

I am new to C # and now I need to decrypt. Any idea how?

I could only decrypt one line using the following code.

 protected void Page_Load(object sender, EventArgs e) { Configuration config = WebConfigurationManager.OpenWebConfiguration("~"); ConnectionStringsSection connSection = (ConnectionStringsSection)config.GetSection("connectionStrings"); //connSection.SectionInformation.ProtectSection("DataProtectionConfigurationProvider"); connSection.SectionInformation.UnprotectSection(); config.Save(); } 

Thanks.

+6
source share
1 answer

I found how to do it here https://msdn.microsoft.com/en-us/library/dtkwfdky(v=vs.100).aspx

I could decrypt only by changing one line of the following code:

 protected void Page_Load(object sender, EventArgs e) { Configuration config = WebConfigurationManager.OpenWebConfiguration("~"); ConnectionStringsSection connSection = (ConnectionStringsSection)config.GetSection("connectionStrings"); //connSection.SectionInformation.ProtectSection("DataProtectionConfigurationProvider"); connSection.SectionInformation.UnprotectSection(); config.Save(); } 
+1
source

All Articles