Update Key Value of AppSettings in Web.config

Last post 10-15-2007 3:41 AM by Benson Yu - MSFT. 5 replies.

Sort Posts:

  • Update Key Value of AppSettings in Web.config

    10-11-2007, 1:35 AM

    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

  • Re: Update Key Value of AppSettings in Web.config

    10-11-2007, 3:40 AM
    • Contributor
      2,808 point Contributor
    • jeroenm
    • Member since 03-20-2007, 9:57 PM
    • Netherlands
    • Posts 500

    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.

    --------------------------------
    Jeroen Molenaar.
  • Re: Update Key Value of AppSettings in Web.config

    10-11-2007, 4:02 AM

    That is not the article.

  • Re: Update Key Value of AppSettings in Web.config

    10-11-2007, 4:34 AM
    • Contributor
      2,808 point Contributor
    • jeroenm
    • Member since 03-20-2007, 9:57 PM
    • Netherlands
    • Posts 500

     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.

    --------------------------------
    Jeroen Molenaar.
  • Re: Update Key Value of AppSettings in Web.config

    10-11-2007, 4:56 AM

    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?

  • Re: Update Key Value of AppSettings in Web.config

    10-15-2007, 3:41 AM
    Answer

    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 .NET
    http://support.microsoft.com/kb/301225/en-us

    How To Write XML to a File in Visual Studio .NET (2002) Professional Edition
    http://support.microsoft.com/kb/301282/en-us

     

    Sincerely,
    Benson Yu
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help. This can be beneficial to other community members reading the thread.
Page 1 of 1 (6 items)