Connection String: Global.asax vs. web.config file

D

D. Shane Fowlkes

Upon reading through my ASP.NET book, I've learned how to place the
connection string in both locations in my application. Just due to habit, I
naturally want to place my SQL Server connection string in the asax
file...but are there really advantages to having in one file over the other?

Thanks
 
S

Steve C. Orr [MVP, MCSD]

Your web.config file is generally considered a better place because it's a
simple text file that is easily updated without needing to recompile
anything and changes go into effect immediately.
 
J

Jeremy

I agree.

I use the web.config file because in our environment I
have to move an application from development to staging
(for testing) and then up to production. So rather than
making the change in the asax file and recompiling every
time before pushing the application up to the next stage I
just open the web.config and make the change.

I guess it's all just preference, whatever you feel most
comfortable in doing, but I vote for web.config

Jeremy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top