I’m writing and installer for an ASP.NET application, and I have a few data fields, (connection strings, smtp servers, etc), that I want the installer to build from user input, encrypt and store in the Web.config file. The issue I am having is that both WebConfigurationManager and ConfigurationManager are both designed to work off existing configuration files. How can I construct a new configuration file, and encrypt it before saving it?
Share
I would recommend starting with a base configuration file that does not contain fields you want, then using
XDocumentorWebConfigurationMangeradd the configuration information and encrypt it.Source: Encrypting and decrypting sensitive data in your web.config files using Protected configuration – Part IV
Code incase the content goes down: