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
narasimman gPosted Nov 6, 2011, 12:38 PM
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 ? :( :( :(
Suthish NairPosted Nov 6, 2011, 9:09 AM
Javeed M ShaikhPosted Nov 5, 2011, 3:55 PM
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..
narasimman gPosted Nov 5, 2011, 3:20 PM
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 ShaikhPosted Nov 4, 2011, 12:53 PM
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();