I Need add custom values to AppSettings in a webservice
i have this code, but nothing happens.
procedure TWebService1.AddStrConn(KeyConn, ValueConn: String);
var
config : System.Configuration.Configuration;
begin
config:=ConfigurationManager.OpenExeConfiguration(System.Reflection.Assembly.GetExecutingAssembly().Location);
config.AppSettings.Settings.Add(KeyConn,ValueConn);
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection('appSettings');
end;
also try
procedure TWebService1.AddStrConn(KeyConn, ValueConn: String);
var
config : System.Configuration.Configuration;
begin
config:=ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings.Add(KeyConn,ValueConn);
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection('appSettings');
end;
You are using OpenExeConfiguration, which is intended for *.exe.config. To open web.config, try something like
It should allow you to save, provided your service has the privileges to do so.