Example:

How to encrypt/decrypt connectionStrings and SessionState section on Web.Config file?

This is a codebehid sample script written on C# to perform Encrypt and Decrypt procedure against few items on Web.Config file. Single ASP.NET page can perform this task easily, so you don’t have to write any code in command prompt.

Declare this namespace:

The code:

Note that there’s two string variable to be fill

This method need identity impersonate setting set to “true” in Web.Config file. In this case i’m using domain user (coz all my dev server under domain controller).

After performing Encrypting and Decrypting method, you should delete the page and identity impersonate section in web.config.