Changes to the web. config will trigger the app to be reloaded by IIS as soon as there are 0 connections left to the app. You can also stop and restart the app pool that the app is assigned to in order to make this happen. You do not need to stop and restart IIS itself.
Web. Config is used for asp.net web projects / web services. App. Config is used for Windows Forms, Windows Services, Console Apps and WPF applications.
Yes, you do:
.Net framework will read the app.config once, and never touch the app.config again. That is why you have to restart the application to pick up the change.
Why does not .Net framework detect that app.config has changed, and refresh all the config data?
The reason is simple, this is not possible in general.
Let’s use Raymond’s “imagine this could be done” logic here...
I've used this before. Essentially this reloads the specified section before retrieving the value. Quite possibly less efficient than a config file watcher that refreshes on demand, but certainly effective used carefully.
ConfigurationManager.RefreshSection("appSettings")
sValue = ConfigurationManager.AppSettings(name)
No, you don't have to. But if you want for changes in app.config
to take effect, you might need to restart it. Or you might want to implement a custom configuration file watcher mechanism which would alter services' settings on the fly.
Yes.
Presumably you mean the appname.exe.config file?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With