Created
February 10, 2020 16:33
-
-
Save shirhatti/b0cb69bfdbb7fd3b32c391ab7cf563f9 to your computer and use it in GitHub Desktop.
Revisions
-
shirhatti created this gist
Feb 10, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ using Microsoft.Web.Administration; namespace MWASample { public class Program { static void Main(string[] args) { var serverManager = new ServerManager(); var config = serverManager.GetApplicationHostConfiguration(); var section = config.GetSection("system.applicationHost/applicationPools"); var collection = section.GetCollection(); var DefaultAppPool = collection[0]; var envVariables = DefaultAppPool.GetChildElement("environmentVariables").GetCollection(); var newElement = envVariables.CreateElement(); newElement.SetAttributeValue("name", "FOO"); newElement.SetAttributeValue("value", "BAR"); envVariables.Add(newElement); serverManager.CommitChanges(); } } }