Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
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?
✍: Guest
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:
<configuration>
<appSettings>
<add key="MyConnectionString" value="...the connection string goes
here..." />
</appSettings>
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, 7218👍, 0💬
Popular Posts:
How To Build WHERE Criteria with Web Form Search Fields? - MySQL FAQs - Managing Tables and Running ...
How Can we change priority & what levels of priority are provided by Dot Net? Thread Priority ca...
.NET INTERVIEW QUESTIONS - How can you avoid deadlock in threading? A good and careful planning can ...
How To Enter Numeric Values as HEX Numbers? - MySQL FAQs - Introduction to SQL Basics If you want to...
Can you explain what is “AutoPostBack” feature in ASP.NET ? If we want the control to automatically ...