Can I Add ConnectionStrings to the ConnectionStringCollection at Runtime?

前端 未结 8 1466
心在旅途
心在旅途 2020-12-15 18:38

Is there a way where I can add a connection string to the ConnectionStringCollection returned by the ConfigurationManager at runtime in an Asp.Net application?

I hav

8条回答
  •  没有蜡笔的小新
    2020-12-15 18:56

    The configuration infrastructure supports very robust encryption through the Windows DataProtection API wich uses a machine specific key to encrypt the configuration sections. This way it would not be possible to read the encrypted data anywhere but on the machine where it was encrypted.

    This is the same API that is used for the Government compliant drive/folder encryption in Windows. Would this stand up to your companies security requirements?

    Either manually or through your deployment automation you can execute this command to encrypt the connectionStrings section of your web.config for a specific web application.

    aspnet_regiis -pe "connectionStrings" -app "/MyCoolWebApplication" -prov "DataProtectionConfigurationProvider"
    

提交回复
热议问题