Using the Windows Registry
You can also use a custom key in the Windows registry to store the connection string, although this is not recommended due to deployment issues.
Advantages
- Security. You can manage access to selected registry keys by using access control lists (ACLs). For even higher levels of security, consider encrypting the data.
- Ease of programmatic access. .NET classes are available to support reading strings from the registry.
Disadvantages
- Deployment. The relevant registry setting must be deployed along with your application, somewhat defeating the advantage of xcopy deployment.
Using a Custom File
You can use a custom file to store the connection string. However, this technique offers no advantages and is not recommended.
Advantages
- None.
Disadvantages
- Extra coding. This approach requires extra coding and forces you to deal explicitly with concurrency issues.
- Deployment. The file must be copied along with the other ASP.NET application files. Avoid placing the file in the ASP.NET application directory or subdirectory to prevent it from being downloaded over the Web.

Comments
Join the conversation! Your thoughts help the community grow.