In one of the application i am developing on ASP.Net. In this application we have been using lots of AppSettings. In the initial development we used ConfigurationManager.AppSettings[""]. but as development progressed we created a utility class in which we would define a static property for each AppSettings. Then issues started to come. Now when application is deployed on testing server and we change any settings on AppSettings it does not have any effect unless we restart the IIS. here is the following code snippet i am using to create static property of AppSettings.
public static class AppSettingsUtil
{
public static string Log4Net
{
get
{
return ConfigurationManager.AppSettings["Log4Net"];
}
}
}
One of the reason i could think of is that , It is a static property so it may be initialized once in its lifetime so next time onwards it may not be fetching values from appsettings .
I know this is an old thread, but something to add.
If you use:
<appSettings file="AppSettings.config" />
Then changes to the external file will not be available until a change to web.config is made or a restart is performed.
But if you change that to:
<appSettings configSource="AppSettings.config" />
The changes to those settings are available in your code immediately without a restart or a web.config change.
I just verified that this is the case with a repeatable test.
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