Hi All,
I would like to list all the web.config files in a directory and edit their values and save it
(Including any server web.config also using credentials . read/write permission will occur i guess.need solution for that also )
Any samples would be helpful
Cheeers
N
Loading

Javeed M ShaikhRank #839 · 2.7K reputationPosted Nov 4, 2011, 8:53 AM EDT
It is not advisable to change values in the web.config file and these values must be stored in database or anyother external storage. But still if you need to modify the config file you can use this snippet:
Configuration config = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
config.AppSettings.Settings["myAppKey1"].Value = "NewValueforAppKey1";
config.Save();
narasimman g146 reputationPosted Nov 5, 2011, 11:20 AM EDT
thanks for your response first,
I am having more than 20 servers, I am in need of changing web config file frequently. Logging into server taking much time. if i use a tool that will save my time.Hopefully u can understand..Wanna change All the attributes present inside the Web.Config XML file
Javeed M ShaikhRank #839 · 2.7K reputationPosted Nov 5, 2011, 11:55 AM EDT
code snippet...
XmlDocument doc = new XmlDocument();
string configFile = Path.Combine(siteFolder, "web.config");
doc.Load(configFile);
.... now process the file....make sure the user has rights..
Suthish NairRank #92 · 22.8K reputationPosted Nov 6, 2011, 4:09 AM EST
narasimman g146 reputationPosted Nov 6, 2011, 7:38 AM EST
I am deploying packages in multiple server frequently, logging into servers and finding web.config and changing will kill my time..if i have a tool to get the web.config of servers using credentials then i can edit and save it in a seconds.
Hope you can understand and its my daily routing process.
Now am doing in this way,
1.Loading the config file in TREEVIEW
2.Letting user to edit the Last Child value (Obvisiouly the value of any attribute)
3. How to save it ? :( :( :(