我只是通過這個代碼讀取web.config文件作爲添加appSettings部分通過C#代碼的web.config
Configuration configuration = WebConfigurationManager.OpenWebConfiguration("~");
AppSettingsSection appSettingsSection = (AppSettingsSection)configuration.GetSection("appSettings");
if (appSettingsSection != null)
{
appSettingsSection.Settings.Remove(key);
config.Save();
}
它正常工作時appSettings
出現在web.config
文件。
我的查詢是在web.config
文件中添加appSettings
標記如果它不存在。
通常您只需編輯配置文件。你爲什麼試圖修改它有問題? –
@Jason Meckley它是我的作品 – GowthamanSS