I am trying to do the same thing as mentioned in the previous previous question. In essence, here is the case (this is exactly the same situation):
My plan is to have these (appSettings) in their own file (Settings.config), to which I will give a modification of the permission to the user of the web process of the account and save all editable settings in this file (for example, forum name, description and etc.).
The problem is that the decision made in this question does not work for me, because instead of saving appSettings in a separate .config file, when I issue a command config.Save(ConfigurationSaveMode.Minimal, false), it replicates all appSettings of a separate file to the appSettings section of the main web.config file (with new changes). Here is my last code (on vb.net):
Public Shared Function GetAppSetting(ByVal setting As String) As String
Dim config As System.Configuration.Configuration = _
WebConfigurationManager.OpenWebConfiguration("~")
Return config.AppSettings.Settings(setting).Value
End Function
Public Shared Sub SetAppSetting(ByVal setting As String, ByVal value As String)
Dim config As System.Configuration.Configuration = _
WebConfigurationManager.OpenWebConfiguration("~")
config.AppSettings.Settings(setting).Value = value
config.Save(ConfigurationSaveMode.Minimal, False)
ConfigurationManager.RefreshSection("appSettings")
End Sub
, , , , , web.config, . , , , 'file =' appSettings web.config, Settings.config appSettings. .config. websconfig appSettings:
<appSettings file="Settings.config">
<add key="RestartApp" value="-1" />
</appSettings>
Settings.config:
<appSettings>
<add key="AppTitle" value="MVC Web Access" />
<add key="DefaultWebpage" />
<add key="CustomCSS" />
<add key="TktsEmailTo" value="email@email.com" />
<add key="EmailFrom" value="email@email.com" />
<add key="EmailFromSMTP" value="mail.email.com" />
<add key="EmailFromPW" value="fakePassword" />
</appSettings>
, Settings.config .save, appSettings web.config ( Settings.config ):
<appSettings file="Settings.config">
<add key="RestartApp" value="-1" />
<add key="AppTitle" value="New title" />
<add key="DefaultWebpage" value="index.aspx" />
<add key="CustomCSS" />
<add key="TktsEmailTo" value="newemail@email.com" />
<add key="EmailFrom" value="newemail@email.com" />
<add key="EmailFromSMTP" value="mail.email.com" />
<add key="EmailFromPW" value="NewFakePassword" />
</appSettings>