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

Modify Web.Config using visual studio or powershell to specific web application

$
0
0

I have a problem in modifying web.config to specificweb application I've search and try so many solution, when ideploy, the modification still affect to all existing web application

here is my code part of my code :

public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {            
            SPWebService service = SPWebService.ContentService;
            SPWebConfigModification myModification = new SPWebConfigModification();            
            SPSite site = new SPSite("http://win-a52s8epvot4:888/");
            SPWeb web = site.OpenWeb();

            myModification.Path = "configuration/appSettings";
            myModification.Name = "add[@key='SQLArchiveConnectionString'][@value='Data Source=WIN-A52S8EPVOT4;Initial Catalog=TRAEmployee;User ID=sa;Password=P@ssw0rd;Persist Security Info=False;']";
            myModification.Sequence = 0;
            myModification.Owner = "administrator";
            myModification.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureChildNode;
            myModification.Value = "<add key='SQLArchiveConnectionString' value='Data Source=WIN-A52S8EPVOT4;Initial Catalog=TRAEmployee;User ID=sa;Password=P@ssw0rd;Persist Security Info=False;' />";
            web.Site.WebApplication.WebConfigModifications.Add(myModification);
            service.Update();
            service.ApplyWebConfigModifications();
        }

is there any suggestion for my problem ?

your reply will greatly help me to finish this problem

Regards,

Jay




Viewing all articles
Browse latest Browse all 11571

Trending Articles



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