using either global.asax or web.config file......

  • Thread starter Thread starter Gish Smith
  • Start date Start date
G

Gish Smith

In classic ASP application I was storing database connection information in
global.asa file. What are the pros and cons of storing
database connection (string) either in global.asax or web.config file ?
Which is the recommended way ? Thanks for your thoughts.
Gish Smith
 
web.config is where you want to store your connection string. This behaves
like an .ini file in apps. You want to do this because it keeps your
configuration outside of your code. Therefore if u need to change any
settings, you need not rebuild your applications, you just edit the
connectionstring key in the web config in one simple location. Esp if you're
dealing with things like database locations or web service urls.
You should never hard code paths in your source code.

The global.asax file is used more for handling global event that occurs in
the application/session. You usually want to initialise session or
application state variables in this file. The global.asax file is optional,
you can delete it if you want.
 
web.config isn't the best choice security wise. For more info, search for
OpenHack at msdn or Google for it.

Eirik M
 
Back
Top