Jul 06, 2017 07:34 AM|Jean Sun|LINK
1. Creating connection string method and call in classes
Do you mean that you want to declare the connection string as a string parameter in your application's code and use the method to get it? This way is more secure, but when you want to change the connection string, you need to modify the source code and republish
2. placing connection string in web.config file and encrypt and decrypt it.
I prefer this approach.
secondly if we encrypt the connection string then while calling the connection string we first need to decrypt it ?
If you encrypt the connection string with ASPNET_REGIIS, It’s very good to know that ASP.NET automatically decrypts the contents of the
Web.Config file when it processes the file. Therefore, no additional steps are required to decrypt the encrypted configuration settings. You can run your existing application by encrypting your
Web.Config file and it will run perfectly without any modification to your existing code.
string ConnString = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;