Question

Reloading configuration without restarting application using ConfigurationManager.RefreshSection

Has anyone got this working in a web application?

No matter what I do it seems that my appSettings section (redirected from web.config using appSettings file=".\Site\site.config") does not get reloaded.

Am I doomed to the case of having to just restart the application? I was hoping this method would lead me to a more performant solution.

Update:

By 'reloading' I mean refreshing ConfigurationManager.AppSettings without having to completely restart my ASP.NET application and having to incur the usual startup latency.

 45  53212  45
1 Jan 1970

Solution

 59

Make sure you are passing the correct case sensitive value to RefreshSection, i.e.

ConfigurationManager.RefreshSection("appSettings");
2009-10-20

Solution

 16

This seems to be a flaw (maybe a bug) when using an external config file for your appSettings. I've tried it using the configSource attribute and RefreshSection simply never works, I'm assuming this is the same when using the file attribute. If you move your appSettings back inside your web.config RefreshSection will work perfectly but otherwise I'm afraid you're doomed.

2008-12-01