Encrypting AppSettings in file external to Web.Config

自作多情 提交于 2019-12-19 05:33:13

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/11784730/encrypting-appsettings-in-file-external-to-web-config

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!