title: Update web.config applicationSettings programmatically with C# (MVC)
body: <p>I want to update web reference Url in web.config applicationSettings at runtime</p>
  
  <p>Here is web config application settings</p>
  
  <pre><code>&lt;applicationSettings&gt;
  &lt;ItineraryBuilder.Properties.Settings&gt;
    &lt;setting name="ItineraryBuilder_SchedulesConnectionsService_SchedulesConnectionsService"
      serializeAs="String"&gt;
      &lt;value&gt;http://www.pathfinder-xml.com/soap/*/services/SchedulesConnections&lt;/value&gt;
    &lt;/setting&gt;
    &lt;setting name="ItineraryBuilder_SalesForceService_SforceService"
      serializeAs="String"&gt;
      &lt;value&gt;https://login.salesforce.com/services/Soap/c/25.0/0DFd00000000Wa6&lt;/value&gt;
    &lt;/setting&gt;
    &lt;setting name="ItineraryBuilder_OAGService_CBWSPublicService"
      serializeAs="String"&gt;
      &lt;value&gt;http://ondemand.oag.com:80/CBWebServicePublic/CBWSPubliclPort&lt;/value&gt;
    &lt;/setting&gt;
  &lt;/ItineraryBuilder.Properties.Settings&gt;
  &lt;/applicationSettings&gt;
  </code></pre>
  
  <p>here is my code using to update </p>
  
  <pre><code>var configuration = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");
  var section = (System.Configuration.ClientSettingsSection)configuration.GetSection("applicationSettings/ItineraryBuilder.Properties.Settings");
  
  System.Configuration.SettingValueElement sv = new System.Configuration.SettingValueElement();
  sv.Equals("https://test.salesforce.com/services/Soap/c/25.0/0DFd00000000Wa6");
  section.Settings.Get("ItineraryBuilder_SalesForceService_SforceService").Value = sv;
  configuration.Save();
  </code></pre>
  
  <p>But it does not update Value, instead remove Value tag from settings</p>
  
  <p>Earlier i was trying to update Web service url, but did not work so i follow this approach, will you please guide me on how to update web service url? </p>
  
  <p>this is what i was doing </p>
  
  <pre><code>SforceService sf = new SforceService();
  sf.Url = "test.salesforce.com/services/Soap/c/25.0/0DFd00000000Wa6";;
  </code></pre>
  
  <p>Please help.</p>