Domanda

I've heard it's a good idea to be able to change config values in a production environment without recycling the app pool.

However, changing would touch the web.config and cause this *anyway.*

Is there any loss of flexibility or decrease in robustness by storing appSettings programmatically if an app pool recycle can't be avoided?

e.g in Pseudo code:

Application_Start() {
  AppSettingHelper.EmailOnException = ConfigurationManager.AppSettings[key];
}

then later, I use: AppSettingHelper.EmailOnException

È stato utile?

Soluzione

Web.config is meant to be used in design time only. If your application changes it's settings in run time, you should really consider storing these settings somewhere else, like in the database.

Changing the web.config file will cause the application to recompile and you will lose all your static variable values and other things. This will also cause a temporary delay for the users. You will also have to manage concurrent updates to the file.

When you change the web.config file you are, in a certain way, changing the application source code.

Take a look at this thread for possibilities to store user settings: What is the best way to store user settings for a .NET application?.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top