Writing to Web.config with C#?

FordPrefect

New Member
How would one go about writing to the Web.config file? ConfigurationSettings is a read only collection. It's awesome for quick reads of information that can't be in a DB(like DB connection info), but how does one write to it? You don't have to deal with the hassle of dealing with the FSO like in ASP, do you?What are you wanting to write to Web.config and why?I'm looking to write some necessary server information to the config file for a program that I'm building. Obviously DB connectivity information can't be stored in the database, because then how do you know how to connect to it? So I planned on using some keys under <appSettings>. Make sense? Or do you have a better idea?i wouldn't put your database connection in the config.web file, the browser displays it as text. Pop it into your global.aspx file where it is secure.Go ahead and try accessing your Web.config file. The server won't allow access to it from the browser(maybe it displayed as text in Beta 1?), which makes it as safe as putting it in the global.asax file.Ok, write to it with Notepad. The way you make it sound, is that you want a C# program to write to it. What's wrong with notepad? Or VS.NET? Or Edit?
 
Back
Top