iefpw
iefpw

Reputation: 7042

Changing web/app.config at runtime

When I change a field in an web or app.config of a C# project, would that value automatically feed into the program without any restarts or interruptions in the program? Is the program always fetching from the config files every time that field is requested or is it cached by the program somewhere. How does this work?

I want a situation where I would change the value in the config, and want that value automatically pulled by the application like instantly. Changes, and program pulls that value instantly.

Upvotes: 0

Views: 234

Answers (2)

Adil
Adil

Reputation: 148110

You are supposed to change the web.config through code, as it results in restart of AppDomain. You should make a new xml file for setting and change it through code.

Upvotes: 1

Jakub Konecki
Jakub Konecki

Reputation: 46008

ASP.NET monitors web.config file and will recycle AppDomain when it notice changes. It will wait for the current requests to be processed and will queue any new requests coming.

So yes, the changes will be pulled be the application, but not instantly and not without interruption (although that depends on your definition of 'instantly').

Upvotes: 2

Related Questions