c# - ConfigurationManager is not refreshing the AppSettings after a new execution -
in web application (c# + asp.net) can use new values on config file (install.properties) when try values using "configurationmanager".
string pathjava = configurationmanager.appsettings["filepathjava"];
i have got in install.properties
<add key="filepathjava" value="c:\program files\java\jre7\bin\java.exe"></add>
i rode can refresh values:
configurationmanager.refreshsection("appsettings");
i did this:
configurationmanager.openmachineconfiguration()
but value not change.
also tried add new key, configurationmanager returns me null value.
you have potential problem...
if change value in web.config
, while site running, reset web site. modification whatsoever files causes iis reset occur.
a solution want, without resetting web site move application settings out of web.config
altogether:
<?xml version="1.0"?> <configuration> <appsettings configsource="appsettings.config"/> </configuration>
and place appsettings in appsettings.config
file:
<?xml version="1.0"?> <appsettings> <add key="filepathjava" value="c:\program files\java\jre7\bin\java.exe"/> </appsettings>
now, can still use configurationmanager.appsettings["filepathjava"]
, , configurationmanager.refreshsection("appsettings")
should work well.
Comments
Post a Comment