Encrypt Connection String in web.config

10 Apr

In this post we will learn how to encrypt connection string in web.config


        1. RunDeveloper Command Prompt for VS2013 as Administrator
        2. Change directory to Microsoft .Net Framework Folder
        3. Choose .Net framework folder v4.0.30319
        4. Create a website in the IIS
        5. Register your web application using aspnet_regiis command
Developer Command Prompt for VS2013

Developer Command Prompt for VS2013

Encrypt Web Config


Encrypt Web Config

Encrypt Web Config







Now look at Encrypted web config file

web config encrypt

web config encrypt

Encrypt  Connection String in web.config Commands


C:\Windows>cd Microsoft.NET

C:\Windows\Microsoft.NET>cd Framework

C:\Windows\Microsoft.NET\Framework>cd v4.0.30319

C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis.exe -site "EncryptDemo" -app "/" -pe "connectionStrings"

aspnet_regiis.exe -site "NameoftheSite" -app "/" -pe "EncryptingTag"

Decrypt  Connection String in web.config Commands

From the above command change -pe to -pd to decrypt

aspnet_regiis.exe -site "EncryptDemo" -app "/" -pd "connectionStrings"
C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis.exe -site "EncryptDemo" -app "/" -pd "connectionStrings"


Leave a Reply

Your email address will not be published. Required fields are marked *