ASP.NET/.NET interview Question - Does encryption of connection strings in web.config file possible? How?
Shivprasad Koirala
<connectionStrings><add name="Constr" connectionString="Data Source=localhost;Initial Catalog=YourDataBaseName; Integrated Security=True"/></connectionStrings>
In the above snippet code you can see that the connection string easily visible by anyone because it is in decrypted format. Hence to prevent or protect the connection string we need to encrypt connection string in such a way that it is not visible to anyone. Step 2: - Just go to Visual Studio Command Prompt and use aspnet_regiis tool to encrypt the defined connection string like below diagram.
Now just execute the Visual Studio Command Prompt and if the encryption is done successfully a message will be displayed like below diagram.
Step 3:- Go to web.config file and you will see that connection string is now in encrypted format like below diagram.
You will be also interested in watching the below video, which are also asked in most of the interviews and favourable question of interviewers.
Please click here to see more ASP.NET and .NET inzterview questions