I am using the following code to remove a web.config modification which added to web.config via one feature
Collection<SPWebConfigModification> applicationModifications = webApplication.WebConfigModifications;
SPWebConfigModification browserCapsConfig = null;
int modsCount = applicationModifications.Count;
for (int i = modsCount - 1; i > -1; i--)
{
if (applicationModifications[i].Owner == "OWNER_NAME")
{
browserCapsConfig = applicationModifications[i];
}
}
if (browserCapsConfig != null)
{
applicationModifications.Remove(browserCapsConfig);
webApplication.Update();
webApplication.WebService.ApplyWebConfigModifications();
}
All web.config modifications are retrieved in collection properly but the thing is while removing it, it is removed from the collection (unable to retrieve it anymore) but not from the web.config. The added modification still there. I tried the same code in SharePoint feature and a console application and getting the same behavior.
Anything missing I should do to remove it from the web.config file?