I encrypt my connection string in the web.config with this code in my aspx load.
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 newbie with c # and for now what I need is decrypt. Any idea how?
I could decrypt only one line using 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.
I found how to do it here https://msdn.microsoft.com/en-us/library/dtkwfdky(v=vs.100).aspx
I could decrypt by only 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();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.