Oct 15, 2010

How to encrypt connection string in web.config

Lets say you want to encrypt the connection string you stored in the ''  element in your ASP.NET website's web.config file.
To encrypt the connection string, you have to use the 'aspnet_regiis' utility.
Open visual studio command prompt and type in the following line (obviously you'll have to provide  your website's path!)

aspnet_regiis -pef "connectionStrings" "fully-qualified-path-to-website-folder"
The above command will encrypt the web.config file at the location provided by you.

Now what if you want to roll back and decrypt the connection ?
Well then just open visual studio command prompt again and fire in this command:

 aspnet_regiis -pdf "connectionStrings" "fully-qualified-path-to-website-folder"
 Happy Coding!

1 comment:

  1. hmm!
    Thanks buddy
    it is a fast,easy and secure solutions