Use configsource in the Web. config file to avoid dynamically modifying Web. config to cause ASP.

Source: Internet
Author: User

Reference:

Http://www.cnblogs.com/sxw_cug/archive/2013/02/28/1785477.html

Http://www.cnblogs.com/jiaxa/p/3326631.html?utm_source=tuicool

Http://www.cnblogs.com/Gyoung/p/3590778.html

As we all know, after modifying the configuration file Web. config in ASP. NET, it causes the application to restart and all sessions (session) are lost. However, the application configuration information in the configuration file is the best choice, in the background to modify the configuration to cause all session loss is very uncomfortable, this time the configuration file will often need to change parameter configuration sectionPut it outside, for example AppSetting Festival.

First, the original Web. config file:



<appSettings>





<add key= "SiteDomain" value= "chinaxx.com"/>
</appSettings>






</configuration>

Two (1/2), now Web. config files



ConfigSource= "Config\appsettings.config"/>






</configuration>

Appsettings.config file in the Config directory of two (2/2) and now

<?xml version= "1.0" encoding= "Utf-8"?>
<appSettings>
<add key= "Cachetimeinfo" value= "/>"
<add key= "Cachetimenews" value= "ten"/>
<add key= "cachetimeproduct" value= "/>"
<add key= "Cachetimetrade" value= "5"/>
<add key= "SiteName" value= "China Fork Net"/>
<add key= "SiteDomain" value= "chinaxx.com"/>
</appSettings>

This will not cause a reboot if the Config\appsettings.config file is modified in the program.

Use configsource in the Web. config file to avoid dynamically modifying Web. config to cause ASP.

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.