Encrypting Web.Config
- Open Command Prompt with Administrator privileges
- At the Command Prompt, enter: cd C:\Windows\Microsoft.NET\Framework\v4.0.30319
This command will narrate you to the framework version folder given. - In case your web Config is located in "D:\Articles\EncryptWebConfig" directory path, then enter the following to encrypt the
ConnectionString
: ASPNET_REGIIS -pef "connectionStrings" "D:\Articles\EncryptWebConfig"Use Aspnet_regiis.exe tool with the–pef
option and specify the application path as shown above.Note: The parameter "connectionStrings
" is case sensitive. - Once you click the enter. You will get the output as follows.
Decrypt connection string
You can always decrypt the connection string if you want, to decrypt you just need follows the commands as follows at the command prompt.
cd C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319
Once after you did you the above command you can execute the preceding one.
ASPNET_REGIIS -PDF "connectionStrings" "F:\Visual Studio\EncryptConnectionString\EncryptConnectionString"
The text ‘connectionString’ is case sensitive as mentioned above
If the command is correct, you can get an output as follows.
Now if you check your Web config again, you can see the connection string has got encrypted. Have a happy coding!
No comments:
Post a Comment