I'm just reading the web.config file through this code as
Configuration configuration = WebConfigurationManager.OpenWebConfiguration("~");
AppSettingsSection appSettingsSection = (AppSettingsSection)configuration.GetSection("appSettings");
if (appSettingsSection != null)
{
appSettingsSection.Settings.Remove(key);
config.Save();
}
It works fine when appSettings is present in the web.config file.
My query is to add appSettings tag in web.config file if it is not present.