I am going to modify web.config in an event receiver project SharePoint 2016. I use this piece of code in FeatureActivated function to get access to the web.config to modify it:
SPWeb myWeb = properties.Feature.Parent as SPWeb;
SPWebApplication spWebApplication = myWeb.Site.WebApplication;
Collection<SPWebConfigModification> webConfigCollection = spWebApplication.WebConfigModifications;
int modCollectioncount = webConfigCollection.Count;
but this code `webConfigCollection.Count return zero. what is wrong with my way?