How to add AppSettings key / value pair's dynamically in web Config file

Last post 02-02-2007 11:05 PM by Steven Cheng - MSFT. 6 replies.

Sort Posts:

  • How to add AppSettings key / value pair's dynamically in web Config file

    02-01-2007, 12:11 AM

    Idea   Is it possible to add Dynamically AppSetting Key / value pair's in webconfig file?

    if yes,

    How? anybody can explain! through C# Coding

    Thanks in advance

    Balakrishnan 

  • Re: How to add AppSettings key / value pair's dynamically in web Config file

    02-01-2007, 1:09 AM
    Answer
    • Loading...
    • MIB426
    • Joined on 04-25-2003, 3:19 AM
    • Taiwan or Australia
    • Posts 842
    James Wu (MIB426)
    .NET is only way to go
    MCP, MCSE, MCDBA, MCSD, MCAD
  • Re: How to add AppSettings key / value pair's dynamically in web Config file

    02-01-2007, 1:14 AM

    hi Balakrishnan,

    i'm not sure if you can modify your web.config via code or not but be aware if you change it then your web app will be surely restarted, causing users to loose session.

    thanks,

    satish.

    Kind Attn: If a reply to your post helped you, kindly mark it as Answered.
    __________________________________________________
    Please save Animals Help World Society For Protection Of Animals,
    Protect these speechless creatures of GOD
  • Re: How to add AppSettings key / value pair's dynamically in web Config file

    02-01-2007, 2:02 AM
    • Loading...
    • LaTtEX
    • Joined on 09-09-2005, 7:39 AM
    • Philippines
    • Posts 47
    Do you want to do this during installation/deployment or after the web application has been deployed alreadY?
    http://dotnet.kapenilattex.com
  • Re: How to add AppSettings key / value pair's dynamically in web Config file

    02-01-2007, 2:35 AM
    I want to do this after the web application has been deployed
  • Re: How to add AppSettings key / value pair's dynamically in web Config file

    02-01-2007, 11:32 PM
    Thanks a lot it's very much helped to meYes
  • Re: How to add AppSettings key / value pair's dynamically in web Config file

    02-02-2007, 11:05 PM

    Yes, you can. In ASP.NET 1.X you have to use file I/O or XML API to modify the web.config file directly. In .NET 2.0. the ConfigurationManager(for ASP.NET you should use WebConfigurationManager class) class provide methods to modify and update application's config file.

    http://msdn2.microsoft.com/en-us/library/system.web.configuration.webconfigurationmanager.aspx 

    However, you should take care that whenever ASP.NET application's web.config file get changed, it will restart. I don't think this should happen very frequent for an server-side application.

    Hope this helps.

Page 1 of 1 (7 items)
Microsoft Communities
Page view counter