c# - web.config - read custom section, change attribute and save it -


i'm trying access specific custom section of web.config file change section attribute value , save it

this config file:

<custom.viewpoint>     <!-- ********** repository ********** -->     <application type="custom.tablet.readerapplication, custom.tablet">       <content-set>         <publications include="periodical" default="ajcli">       </content-set>     </application>     <!-- ********** security ********** -->     <web.authentication enabled="false">       <session persist="true" expiration="30.00:00:00" />     </web.authentication> <custom.viewpoint> 

what i'm trying access web.authentication attribute enable true false , vice versa. want testing purposes, instead of going each folder , changing attribute false want able program when i'm done testing want turn on when done testing.

i found code access section isn't working me. appreciated.

var configuration = webconfigurationmanager.openwebconfiguration("~"); var section = (connectionstringssection)configuration.getsection("connectionstrings"); section.connectionstrings["myconnection"].connectionstring = "data source=..."; configuration.save();    var config = webconfigurationmanager.openwebconfiguration("~/appfolder"); var sectionx = config.getsection("custom.viewpoint");  don't know how access nodes here 


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -