Runtime editing in web.config

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Spanco
    New Member
    • Mar 2007
    • 13

    Runtime editing in web.config

    My web application is using multiple databases according to user requirement.

    Means user can choose the database from available database ( Available databases are maintained in web.config file in form of a key - values)

    Now when I have to change the available connection or have to add a new one then I have to go to web.config and edit that one.



    Now the new requirement is to update web.config from an admin module which resides in different independent application.

    My Question is ...

    (1) Can I change ( Access) my present web.config file from this independent application and if yes then how do i change it.

    (2) If I can't then what should I do.

    Making admin module in the present application is my last option.
  • dip_developer
    Recognized Expert Contributor
    • Aug 2006
    • 648

    #2
    Originally posted by Spanco
    My web application is using multiple databases according to user requirement.

    Means user can choose the database from available database ( Available databases are maintained in web.config file in form of a key - values)

    Now when I have to change the available connection or have to add a new one then I have to go to web.config and edit that one.



    Now the new requirement is to update web.config from an admin module which resides in different independent application.

    My Question is ...

    (1) Can I change ( Access) my present web.config file from this independent application and if yes then how do i change it.

    (2) If I can't then what should I do.

    Making admin module in the present application is my last option.
    Read this article.Hope it will help you.
    Edit web.config in runtime.

    but keep in mind.....

    it's not a good idea to edit web.config at runtime.Realize that any change you make to web.config will result in the application being restarted on your webserver. This means all the sessions go bye-bye. The best way to store dynamic data like this, doesn't have to be in web.config, rather is in a database, or a xml config file you can parse at runtime, without interrupting the flow of things.

    Comment

    • Spanco
      New Member
      • Mar 2007
      • 13

      #3
      Thanks 4 reply....

      What i Know that in ASP.NET 2.0 IIS Does not restart the application,I may be wrong please reply me.




      Originally posted by dip_developer
      Read this article.Hope it will help you.
      Edit web.config in runtime.

      but keep in mind.....

      it's not a good idea to edit web.config at runtime.Realize that any change you make to web.config will result in the application being restarted on your webserver. This means all the sessions go bye-bye. The best way to store dynamic data like this, doesn't have to be in web.config, rather is in a database, or a xml config file you can parse at runtime, without interrupting the flow of things.

      Comment

      • dip_developer
        Recognized Expert Contributor
        • Aug 2006
        • 648

        #4
        Originally posted by Spanco
        Thanks 4 reply....

        What i Know that in ASP.NET 2.0 IIS Does not restart the application,I may be wrong please reply me.
        see this



        it's also a good site to consult

        Comment

        • Spanco
          New Member
          • Mar 2007
          • 13

          #5
          Thanks Really good Stuff.

          But what iam trying to do is : There is a Seperate application to edit the web.config of a currently running site.

          Iam trying it throught web service if it is done sucessfull i will get back to you.

          bi

          Originally posted by dip_developer

          Comment

          • Sandeepcs3
            New Member
            • May 2010
            • 1

            #6
            Here is a link that provide good explanation of editing web.config at runtime

            Comment

            Working...