Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

SPWebConfigModification not updating the web config?

$
0
0
I am trying to add a key in webconfig of my sharepoint web application through a site colleciton feature.

i am using a piece of code in feature receiver but i am getting following errors

    First i was getting error saying that it is trying to update all the web application whereas i need only the web app where my feature gets actvated.

    Now i am getting access denied, i added my appliation pool account to sp farm group and still i get the access denied error. any help

here is the code
     public static void AddAppSettingsKeyValue(string key, string value, SPWebApplication webApp)
    {
        //SPWebService service = SPWebService.ContentService;
        SPSecurity.RunWithElevatedPrivileges(delegate()
       {
           if (!string.IsNullOrEmpty(key) && !string.IsNullOrEmpty(value) && webApp != null)
           {
               SPWebConfigModification modification = GetModification(key, value);
               if (!webApp.WebConfigModifications.Contains(modification))
               {
                   webApp.WebConfigModifications.Add(modification);
                   //service.WebConfigModifications.Add(modification);
                   //service.Update();
                   webApp.Update();
                   webApp.Farm.Services.GetValue<SPWebService>().ApplyWebConfigModifications();

               }
           }
           else
               throw new ArgumentNullException();
       });

    }



kukdai


Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>