このコードを介して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存在しない場合にファイルに追加することです。