Asp.net Web. Config saving settings cause the website to be restarted from time to time

Source: Internet
Author: User

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>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.