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:

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:
http://msdn.microsoft.com/en-us/library/k6h9cz8h%28VS.80%29.aspx


Table of Contents  Back

Encrypt_the_Web_Configuration_Information