0
<appSettings>
    <add key="webpages:Version" value="2.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="PreserveLoginUrl" value="true" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
    <add key="ServerName" value="localhost" />
    <add key="DatabaseName" value="amc_live" />    
    <!--<add key="PwdName" value="123456" />-->
    <add key="LogError" value="1" />
  </appSettings>


  <secureAppSettings>
    <add key="UserName" value="root" />
    <add key="Password" value="12345" />
  </secureAppSettings>

here in the above code... after encrypt of securityAppSetting i cant able to update that programatically .

i use below code to update

xmlDoc.Load(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);
xmlDoc.SelectSingleNode("//secureAppSettings/add[@key='Password']").Attributes["value"].Value = Pass;
xmlDoc.Save(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);
ConfigurationManager.RefreshSection("secureAppSettings");

but in below line of code it is throwing error like "Object reference not set to an instance of an object." when i try to update.

xmlDoc.SelectSingleNode("//secureAppSettings/add[@key='Passw‌​ord']").Attributes["‌​value"].Value = Pass;

Thanks.

Surya
  • 265
  • 1
  • 3
  • 10
  • please include all information you have about error messages/exceptions that occur, "not working" and "unable to" is too vague. – Cee McSharpface Nov 03 '17 at 11:17
  • xmlDoc.SelectSingleNode("//secureAppSettings/add[@key='Password']").Attributes["value"].Value = Pass; for the above line it is showing "Object reference not set to an instance of an object." error – Surya Nov 03 '17 at 11:23
  • @user8878681 Please edit this into your question for clarity, thanks! – Pax Vobiscum Nov 03 '17 at 12:04
  • Please ensure the xml file, after encryption, has the right nodes and attributes present. – Lasse V. Karlsen Nov 03 '17 at 12:26

0 Answers0