I wrote an ASP. NET article a few days ago to read and write Web. Config. Then I did use the method in this article to rewrite the configuration module of my website. The results showed that the website was restarted from time to time, which was very strange.
After the study, I found that as long as the Web. Config is modified, IIS will restart the website. It does not restart immediately and seems to have a threshold value like GC. However, my settings must be saved in Web. Config. Can this be swollen? After some Google attempts, I finally found a solution. Now it seems that the website has been restarted.
The method is to write the configuration information in the appSettings node of Web. Config to another file, and then set the configSource attribute of the appSetting node to point to the config file.
The specific statement is as follows (from the original author's blog ):
Web. in config, the deleettings section has a property: configSource, which can specify an external file path for storing the deleettings (only the relative path is supported ), the modification of this external file will not cause page re-compilation, and its changes can be immediately ASP. NET Runtime Library detected. You can give two birds a second.
Configuration of appSettings in Web. config:
| The code is as follows: |
Copy code |
<? Xml version = "1.0" encoding = "UTF-8"?> <Configuration> <Etetaskconfigsource = "settingswebappsetask. config"/> </Configuration> content of the external file SettingsWebAppSettings. config: <? Xml version = "1.0" encoding = "UTF-8"?> <AppSettings> <add key = "SMTPServerAddress" value = "0.0.0.0"/> </appSettings> |