Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to change web.config without ending all user sessions?

Is it possible to change the web.config file without giving all the users on the site a new session?

like image 746
Espo Avatar asked Sep 22 '09 10:09

Espo


People also ask

What happens when you change the web config file at run time?

the answer i found :- ASP.NET invalidates the existing cache and assembles a new cache. Then ASP.NET automatically restarts the application to apply the changes.

Can we have 2 web config?

Yes you can have two web. config files in application. There are situations where your application is divided in to modules and for every module you need separate configuration. For example if you have a application which has two modules lets say accounts and sales.

Does changing web config restart application?

When you edit the web. config, It will restart the AppDomain (NOT AppPool) of that web application and clears the all occupied resources and memory.

What happens if I delete web config?

config, unlike any other file, can be deleted.. Yes the web. config could be removed you can test it. The Website will give you error once you have removed it.


1 Answers

You can move the volatile portions of the web.config into external files and then set up IIS to not restart applications when those files change.

In the example below, application and connection-string settings have been moved to another file, outside of the web.config.

<?xml version="1.0"?>
<configuration>

  <appSettings configSource="appSettings.config"/>

  <connectionStrings configSource="connections.config"/>   

</configuration>

Once that's done, you can make changes to app settings (or whatever else you put in the external file) without editing the web.config.

You can also visit the machine.config and play with the restartOnExternalChanges attribute, but this should be used with caution as it could have unintended consequences. Some sections, such as app-settings, already have this set to "false".

<section name="appSettings" restartOnExternalChanges="false">

More details are available in this OdeToCode article.

like image 126
Brad Tutterow Avatar answered Sep 21 '22 15:09

Brad Tutterow