This is the encryption and decryption of sections of web.config file ( for ex. AppSettings, Connection string)
- Open Command Prompt as ADMINISTRATOR.
- Open the Framework folder path in command prompt "C:\Windows\Microsoft.NET\Framework\v4.0.30319"
- Execute the command for Encrypt the Connection String of Web.config file.
aspnet_regiis.exe -pe connectionStrings -app "/<<VirtualDirectoryName>>"
- Execute the command for Encrypt the AppSetting of Web.config file.
aspnet_regiis.exe –pe appSettings -app "/<<VirtualDirectoryName>>"
- Add Permission on machine.config file (Using Command)
aspnet_regiis -pc "NetFrameworkConfigurationKey" -exp
aspnet_regiis -pa "NetFrameworkConfigurationKey" "ASPNET"
aspnet_regiis -pa "NetFrameworkConfigurationKey" "NETWORK SERVICE"
aspnet_regiis -pa "NetFrameworkConfigurationKey" "NT AUTHORITY\NETWORK SERVICE"
aspnet_regiis -pa "NetFrameworkConfigurationKey" "IIS APPPOOL\<<Application Pool>>" -full
Note- To Decrypt the File use Following Command.
aspnet_regiis.exe -pd connectionStrings -app "/<<VirtualDirectoryName>>"
aspnet_regiis.exe -pd appSettings -app "/<<VirtualDirectoryName>>"