Sign in | Join
Last post 10-15-2007 3:41 AM by Benson Yu - MSFT. 5 replies.
Sort Posts: Oldest to newest Newest to oldest
Hi,
I want to update the key value of AppSettings in Web.config File
But I need the code in C# for Asp.net 1.0.
Asp.net 2.0 code id available. But I need only in Asp.net 1.0
Can any one help me in this regard.
Muhammad Zeeshanuddin Khan
Hello Muhammed,
As fas as I know, it's not possible in .NET version 1.x to update config files.
See the following article: http://msdn2.microsoft.com/en-us/library/1xtk877y(VS.71).aspx
Jeroen Molenaar.
That is not the article.
The article says:
Note: Managed code can use the System.Configuration API to read settings from the configuration files, but not to write settings to those files.
Jeroen.
So can you tell me,
What way will I choose to store global values in Asp.net 1.0?
If I choose Global.asax file. Then the value in Global.asax file is change after refresh or restart the system.
How will I do it?
zeeshanuddinkhan@hotmail.com: What way will I choose to store global values in Asp.net 1.0? If I choose Global.asax file. Then the value in Global.asax file is change after refresh or restart the system.
Hi zeeshanuddinkhan,
You can add a xml file in your project and save the values in it, then we read them during the application start event handler of Global.asax and modify it anywhere.
We can read xml data by using XmlTextReader class, and write data to the xml file by using XmlTextWriter class. For the demo code, please refer to the following link:
How to read XML from a file by using Visual Basic .NEThttp://support.microsoft.com/kb/301225/en-us
How To Write XML to a File in Visual Studio .NET (2002) Professional Editionhttp://support.microsoft.com/kb/301282/en-us