Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Encrypting AppSettings in file external to Web.Config

I currently use this method to encrypt the AppSettings section of my application's web.config file: aspnet_regiis.exe -pe "appSettings" -site "MySite" -app "/"

But now I have moved some settings out to another file using the element

<appSettings file="IndividualAppSettings.config" >

I can still encrypt the app setting in the web.config, but is there any way to encrypt the content of the additional IndividualAppSettings.config file?

like image 354
Phil Avatar asked Aug 02 '12 19:08

Phil


People also ask

How do I encrypt an entire web config file?

Encrypting a Web Configuration Section To encrypt configuration file contents, use the Aspnet_regiis.exe tool with the –pe option and the name of the configuration element to be encrypted. Use the –app option to identify the application for which the Web.


1 Answers

We do this all the time as we use external files for each of our environments.

First your appSettings element needs to look like this:

<appSettings configSource="IndividualAppSettings.config" />

Next, we call the encryption from the cmdline using:

aspnet_regiis -pe "appSettings" -prov "{0}" -site {1} -app "/"

where:

  • {0} is the name of your encryption provider specified in the web.config.
  • {1} is the Id of your site in IIS
like image 154
Adam Spicer Avatar answered Sep 19 '22 22:09

Adam Spicer