Working with Multiple Web Config C#
- by Hiyasat
Hi All,
I have 2 projects, each one have a WebConfig file, and i want to edit the 2 webconfig files from one place, and i try to do this:
string configPath = "/";
Configuration confUI = WebConfigurationManager.OpenWebConfiguration("~");
Configuration confProtocol = WebConfigurationManager.OpenWebConfiguration(configPath);
AppSettingsSection appSettingsUI = (AppSettingsSection)confUI.GetSection("appSettings");
AppSettingsSection appSettingsProtocol = (AppSettingsSection)confProtocol.GetSection("appSettings");
if (appSettingsUI != null & appSettingsProtocol != null)
{
appSettingsUI.Settings[key].Value = value;
appSettingsProtocol.Settings[key].Value = value;
confUI.Save();
confProtocol.Save();
}
The problem that confProtocol is set to empty.
How to set The WebConfig path of the Protocol Project from the UI Project?