我只是通过此代码阅读 web.config 文件
Configuration configuration = WebConfigurationManager.OpenWebConfiguration("~");
AppSettingsSection appSettingsSection = (AppSettingsSection)configuration.GetSection("appSettings");
if (appSettingsSection != null)
{
appSettingsSection.Settings.Remove(key);
config.Save();
}
appSettings
当文件中存在时,它可以正常工作web.config
。
如果文件不存在,我的查询是appSettings
在文件中添加标签。web.config