Encrypt or Decrpyt the Web.Config Section

This is the encryption and decryption of sections of web.config file ( for ex. AppSettings, Connection string)

  1. Open Command Prompt as ADMINISTRATOR.
  2. Open the Framework folder path in command prompt "C:\Windows\Microsoft.NET\Framework\v4.0.30319"
  3. Execute the command for Encrypt the Connection String of Web.config file.

    aspnet_regiis.exe -pe connectionStrings -app "/<<VirtualDirectoryName>>"
     
  4. Execute the command for Encrypt the AppSetting of Web.config file.

    aspnet_regiis.exe –pe appSettings -app "/<<VirtualDirectoryName>>"
     
  5. 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>>"