• Encrypt the Web Configuration Information
  • Encrypt the Web Configuration Information
  • "78c59ec7-e995-4fd1-8bc9-5452dcbdd4f7
  • After you decrypt and retrieve the information you need from the web.config file, it is highly recommended that you encrypt the web.config file for security.
  • To encrypt configuration file contents, open a command prompt and use the Aspnet_regiis.exe tool with the following parameters:
  • -pe switch, for encryption, followed by the name of the configuration element to be encrypted enclosed in quotes; in this case "connectionStrings"
  • -app switch, to identify the application (virtual directory), followed by the name of the application (virtual directory) enclosed in quotes
  • -site switch, to identify the site number where the application (virtual directory) resides, followed by the site ID or identifier enclosed in quotes; see the
  • Decrypt the Web Configuration
  • The following command encrypts the connectionStrings element in the Web.config file for the ASP.NET application (virtual directory) ODSContent. In the first example the application (virtual directory) is assumed to be from Web site 1 (most commonly the Default Web Site in IIS). The encryption is performed using the RsaProtectedConfigurationProvider specified in the machine configuration.
  • Generic syntax:
  • C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis -pe "connectionStrings" -app "/<Virtualdirectory>" -site "<siteID or Indentifier>"
  • Example when using the Default Web Site:
  • C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis -pe "connectionStrings" -app "/ODSContent" -site "1"
  • Example when using a different Web Site:
  • C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis -pe "connectionStrings" -app "/ODSContent" -site "4567890"
  • Additional Reference: