c# - KeyValue pair is being added to web.config file although file property is defined -



c# - KeyValue pair is being added to web.config file although file property is defined -

configuration config = system.web.configuration.webconfigurationmanager.openwebconfiguration("~"); config.sectiongroups.add("testing", new configurationsectiongroup()); configurationsectiongroup testing = config.sectiongroups["testing"]; testing.sections.add("subsec", new appsettingssection() {file="tst.config" }); keyvalueconfigurationcollection settings = ((appsettingssection)testing.sections["subsec"]).settings; settings.add("tst", "ok"); config.save();

the result is:

<sectiongroup name="testing" type="system.configuration.configurationsectiongroup, system.configuration, version=4.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a" > <section name="subsec" type="system.configuration.appsettingssection, system.configuration, version=4.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a" /> </sectiongroup> <testing> <subsec file="tst.config"> <add key="tst" value="ok" /> //this should not here must added tst.config file </subsec> </testing>

why not adding settings file?

you should able set config source programmatically (instead of file) so:

configurationsection subsec = config.getsection("testing/subsec"); subsec.sectioninformation.configsource = "tst.config";

c# asp.net configuration web-config

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -