Saving a configSection from code, preventing restart

Magnus Rahl
Member since: 2008

If i create a config section in web.config, which resides in a separate file (by using the configSource attribute), can I write to this section from code and persist the changes?

It seems I can create read/write properties in my derived System.Configuration.ConfigurationSection class, but will set values be persisted? I only find a Save method for the System.Configuration.Configuration class, which I suppose would save the whole web.config and restart the application? Can I save just my section somehow, updating only my separate config file and avoiding a restart?

#29478 Apr 28, 2009 16:12
  • Maras M
    Member since: 2007

    Take a look here: 

    #29479 Apr 28, 2009 16:39
  • Magnus Rahl
    Member since: 2008

    Thanks, it's a good FAQ item, however it does not really cover my issue. I want to be able to change the file from code (preferably using the Configuration classes, not by operating directly on the config file). The issue is how to save only the file associated with my config section (and not web.config) from code, or if values are instantly persisted to file when changed in my ConfigurationSection class.

    #29483 Apr 28, 2009 18:54