Which is the best place to store ConnectionString in Dot Net Projects?
Which is the best place to store ConnectionString in Dot Net Projects? I am about to deploy my first ASP.NET project. But, I was used to store my variables, such as connection strings, in the global.asa file, in an application. However, these variables are different on my development and production server. If I use the global.asax file, then it is in the code behing, compiled part. Thus I can't change the setting on my production server. So where is the right place to save my connecting string?
The Web.config file might be a good place. In the system.configuration namespace, you can find the appropriate methods to access this file in you application.
That's what I have done - here's part of my Web.config file:
<add key="MyConnectionString" value="...the connection string goes here..." />
I then retrieve it using ConfigurationSettings.AppSettings["MyConnectionString"]
I also set the BuildAction property of the Web.config file to None, to stop it overwriting the version on the live server.
2009-03-18, 6793👍, 0💬
How To Merge Cells in a Row? - XHTML 1.0 Tutorials - Understanding Tables and Table Cells If you wan...
How do we enable SQL Cache Dependency in ASP.NET 2.0? Below are the broader steps to enable a SQL Ca...
How To Create an Add-to-My-Yahoo Button on Your Website? - RSS FAQs - Adding Your Feeds to RSS News ...
What Happens If a Hyper Link Points to a Music File? - XHTML 1.0 Tutorials - Understanding Hyper Lin...
How To Manage Transaction Isolation Level? - Oracle DBA FAQ - Introduction to PL/SQL Transaction iso...