application settings

A

Andy B

How hard is it to access/modify application settings in the web.config from
web pages?
 
A

Andy B

"Which means that, apart from very exceptional circumstances, modifying
web.config at runtime is almost always the wrong solution - what are you
trying to achieve here...?"

I need to have a set of application settings that can be changed and used in
the website. Kind of like system settings profile instead of a user profile.
For an example, a setting I want to have is "Number of News articles to show
on home page?" I just don't know where the best place to keep these would
be. a DB doesn't seem to be too practicle for something like this. Possibly
some sort of settings file of some kind?
 
G

George

Sorry, I just jump in.

I use external XML file which is desterilized into my 'Config' object with
XmlSerializer when application loading (event in Global.asax). And in code I
am using that Config object

(in Psedoucode)
class clsGlobal
{
static public clsConfig _objConfig;
public static void Init()
{
_objConfig = XmlSerializer.Deserialize('~/my.xml');
}
}

Use in code.
int iLinesPerPage = clsGlobal._objConfig._iLinesPerPage;

-----------------------------------------------
To avoid watching my.xml for changes I create some dummy.aspx page (only me
or admin knows about). Which does only

clsGlobal.Init();
Response.Write("OK");

Then whenever i change my.xml i hit dummy.aspx to refresh new settings.
So basically the same thing as if in web.config except i avoid restarting
application.

But of course as Mark said you need to determine where to store your config
values based on the use. If user needs to be able to change that kind of
settings then my way might be not good idea.


George.
 
A

Andy B

"Do you need to change this value on a regular basis?"

I don't think this particular value will need to be changed on a regular
basis. Because of the nature of the settings, I would expect that they will
be used with some regularity (at least I need to program for the
possibility).

"Do you need to change this value while the site is in use?"

All of the settings I am thinking about need to be set while the application
is in use and running.
 

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

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top