Last post Sep 08, 2015 02:08 PM by PatriceSc
Sep 01, 2015 01:50 PM|zhshqzyc|LINK
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?
Sep 02, 2015 01:08 AM|HostingASPNet|LINK
The next site connection will open the new DB connection. There should be not data lost if you configured the SQL server correclty.
Sep 02, 2015 08:42 AM|zhshqzyc|LINK
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.
Sep 03, 2015 02:04 AM|Angie xu - MSFT|LINK
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.
Sep 03, 2015 08:31 AM|zhshqzyc|LINK
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?
Sep 08, 2015 02:08 PM|PatriceSc|LINK
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 ;-)