Global Constants

D

David

Hey evryone,
I have a ASP.NET project that I'm working on and have been using a
static class to store all my global constant information eg.
MyGlobalClass.MyConnectionString. This has worked out well but it means
that if I want to change any of the values I need to recompile.
The examples I have seen have retrieved values from Web.Config file. I
don't really want to do this because it would mean writing to this file
on a regular basis and I think that restarts the application as well,
and I'm also not too sure of how to retrieve these values from my
business layer that is not really part of the web side of the project.
I could have a class that accepts a connection string as an argument
that connected to a database for initialization but then every time I
used it I would need to get this data all over again.
Any ideas/suggestions?
Cheers,
David.
 
?

=?iso-8859-1?Q?Anders=20Nor=e5s?=

Constants such as connection strings don't change that often, so even though
the application will restart when the config file changes, web.config is
still the best place to store such values. Use the Application object to
store global values used throughout the application.

Anders Norås
http://dotnetjunkies.com/weblog/anoras/
 
D

David

I was kind of happy with the structure I had until I came to coding
some user data pages where there are values stored in a database to do
with content. I figured I could store all this information in a single
table with an id/value kind of structure, so although the connection
string type information wouldn't change that often the other user data
would and I recon it would be good to store them in the same place. The
other issue is if I do use the web.config file how do I retrieve these
values from my business layer? Do I need to add a reference to the web
application to each of my business classes?
 

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

Similar Threads


Top