Click here to Skip to main content
15,920,111 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Let us consider a web.config file deployed from website....

let us take another project say console application or some class file then is it possible to read that web.configuration file and add some tags in that web.config file

i just want to add these lines in to it


XML
<system.webServer>
    <modules>
      <add name="sample" type="sample.class" />
    </modules>
  </system.webServer>



Waiting for your valuable comments
Posted
Updated 22-Jun-12 1:31am
v2
Comments
bbirajdar 22-Jun-12 7:27am    
No efforts

You are just going to have to use XmlDocument or XDocument (3.5) to parse the file.

Look at the links below for headstart:

http://www.dotnetcurry.com/ShowArticle.aspx?ID=102[^]

http://stackoverflow.com/questions/360024/how-do-i-set-a-connection-string-config-programatically-in-net/1312739[^]

Note: I wouldn't recommend modifying web.config directly in production website. Why not use another xml file to store the runtime configurations?
 
Share this answer
 
Comments
gowthammanju 22-Jun-12 7:50am    
can u provide me some samples through xmlreader/ xmlwriter classes for modifying web.config
bbirajdar 22-Jun-12 8:47am    
http://lmgtfy.com/?q=xmlreader%2F+xmlwriter+classes+for+modifying+web.config

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900