471,350 Members | 1,865 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 software developers and data experts.

Global Constants

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?

Nov 27 '05 #1
2 3710
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
Nov 27 '05 #2
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?

Nov 27 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by .NET beginner | last post: by
8 posts views Thread by Mark Rae | last post: by
4 posts views Thread by Amadelle | last post: by
8 posts views Thread by Marty | last post: by
1 post views Thread by 2obvious | last post: by
4 posts views Thread by Dave | last post: by
5 posts views Thread by Will | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.