Click here to Skip to main content
15,886,780 members
Articles / Security

Encrypt Connection String in web.config

Rate me:
Please Sign up or sign in to vote.
2.33/5 (2 votes)
9 Feb 2015CPOL 9.6K   6   1
In this post we will learn how to encrypt connection string in web.config

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

Implementation

  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
Image 1
Developer Command Prompt for VS2013
Image 2
Encrypt Web Config

Image 3

Image 4

Now look at Encrypted web config file

Image 5

web config encrypt

Encrypt  Connection String in web.config Commands

C:\Windows\system32>cd..

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"

The post Encrypt Connection String in web.config appeared first on Venkat Baggu Blog.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) eBiz Solutions http://venkatbaggu.com/
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralMy vote of 1 Pin
Member 188040310-Feb-15 21:37
Member 188040310-Feb-15 21:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.