I want to encrypt common.config, not the Web.config file. Common.config is in a different location than the web.config. The web.config file is connected to the common.config.
web.config:
<appSettings file="C:\Users\ja\Documents\common.config">
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
common.config:
<appSettings>
<add key="myKey" value="This is the Value"/>
</appSettings>`
This works for the web.config file:
aspnet_regiis.exe -pef appSettings c:\Users\ja\Desktop\test\webapp\webapp -prov "RsaRpotectedConfigurationProvider"
But when I try to encrypt the common.config file:
aspnet_regiis.exe -pef appSettings c:\Users\ja\Document\ -prov "RsaRpotectedConfigurationProvider"
I get this error:
The configuration for physical path 'c:\Users\ja\Document\' cannot be opened
I found workaround to solve this issue. Hope it helps.
Rename your common.config to web.config temporarily.
Add configuration as root element to this file. So your common.config will look like as follows.
Run encrypt command.
aspnet_regiis.exe -pef appSettings c:\Users\ja\Document\ -prov "RsaProtectedConfigurationProvider"
Open encrypted file and remove Configuration tags.
Rename file to Common.config PS: I deleted my original comments posted on this thread.
It doesn't look like you supplied the full path:
c:\Users\ja\Document\
vs
C:\Users\ja\Documents\common.config
If the syntax requires the directory, Document is still missing the 's'