Saturday, September 25, 2010

Add system.serviceModel to web.config


Here is the code built on the Sharepoint API that will add WCF/web service configuration, system.serviceModel to web.config.

            SPWebConfigModification item = new SPWebConfigModification();
            item.Name = "system.serviceModel";
            item.Value = " <>... ";
            item.Path = "configuration";
            item.Sequence = 0;
            item.Owner = "owner";
            item.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode;
                SPWebApplication parent = properties.Feature.Parent as SPWebApplication;
                if (parent != null)
                    // To know why i have used Clear(), read this


Same code can be used to add any entires to web.config by giving respective path.
To know other approaches of modifying web.config read Ways to Modify web.config


No comments:

Post a Comment