locked
Change web.config RRS feed

  • Question

  • User-1907931422 posted

     I heard that ASP.NET web.config gets updated, the whole application gets restarted which means the web.config gets reloaded. Just wonder, during the transition time, any data lost? For example, we change the connection string to point a different DB but the production is reading data from a database at the same time.

    What is under the hood?

    Tuesday, September 1, 2015 1:50 PM

Answers

  • User753101303 posted

    AFAIK no. Likely what Angie meant is that you'll update the web.config, current requests are completed, the application restarts automatically and then at this point you are using the new configuration and in particular the new connection string.

    It still depends on some other factor though. For example if someone is just looking at a web form in his browser without interacting with the server, then you change the web.config to point to another db and then the user tries to validate his changes, it is still possible it could cause issues. Changing the db that way is not really usual. Not sure what is your scenario.

    For a db change I would likely plan a downtime and would inform users about it if you can. Or at some point when you have to do something you shouldn't, you have to go ahead and do it ;-)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 8, 2015 2:08 PM

All replies

  • User-1315512054 posted

    Hello,

    The next site connection will open the new DB connection. There should be not data lost if you configured the SQL server correclty.

    Regards

    Wednesday, September 2, 2015 1:08 AM
  • User-1907931422 posted

    Yes, I think so. But when the application restart if a new web.config updated? I mean if I change the web.config during the the middle process reading the old DB.

    Wednesday, September 2, 2015 8:42 AM
  • User-166373564 posted

    Hi,

    But when the application restart if a new web.config updated? I mean if I change the web.config during the the middle process reading the old DB.

    After you modify the database connection, and update the web.config, it will use new schema after application restart.

    With regards,

    Angie

    Thursday, September 3, 2015 2:04 AM
  • User-1907931422 posted

    Oh! I thought that the system would have File Watcher function.  It would automatically read the new config. So according the answer, it is not. We have to manually restart the application?

    Thursday, September 3, 2015 8:31 AM
  • User753101303 posted

    AFAIK no. Likely what Angie meant is that you'll update the web.config, current requests are completed, the application restarts automatically and then at this point you are using the new configuration and in particular the new connection string.

    It still depends on some other factor though. For example if someone is just looking at a web form in his browser without interacting with the server, then you change the web.config to point to another db and then the user tries to validate his changes, it is still possible it could cause issues. Changing the db that way is not really usual. Not sure what is your scenario.

    For a db change I would likely plan a downtime and would inform users about it if you can. Or at some point when you have to do something you shouldn't, you have to go ahead and do it ;-)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 8, 2015 2:08 PM