A very cool feature of ASPNET_REGIIS tool is to encrypt and decrypt config sections of Web.Config file.
Here is one example for your reference.
encrypt:
aspnet_regiis -pef [sectionName] "D:\inetpub\wwwroot\" -prov DataProtectionConfigurationProvider
decrypt:
aspnet_regiis -pdf [sectionName] "D:\inetpub\wwwroot\" -prov DataProtectionConfigurationProvider
Example :
aspnet_regiis -pef "system.web/identity" D:\inetpub\wwwroot\thresholdui -prov DataProtectionConfigurationProvider
2 comments:
Do not put the file name in the command.
aspnet_regiis -pef takes the webApplicationDirectory as a parameter, and should not include the file name of the web.config;
You can easily apply the same solution as the web.config you just have to rename your app.config to web.config, encrypt with the aspnet_regiis tool and then rename it back to app.config.
Rename app.config to web.config
Open command prompt and type:
%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis -pef "connectionStrings" c:\ (stop at folder level and don't put the trailing "\")
rename web.config back to app.config
You can open it in notepad to see the encrypted file. In visual studio you will see it's decrypted. You can use your connection string the same way as if it was not encrypted.
Post a Comment