Configsource in Web. config

Source: Internet
Author: User

In large projects, there may be a third-party class library configuration such as: LOG4.NET,AOP framework UNITY,WCF, or custom configuration, resulting in the Web. config content too much, difficult to maintain, affecting the config initialization.

At this point we can use ConfigSource to split the Web. config to improve flexibility and legibility.

Separate the appsetting and ConnectionString configurations, as in the following code.

ConfigSource="configs\appsettings.config"configSource=" Configs\connectionstrings.config " />

In the sibling directory:

The Appsetting.config code is as follows:

<appSettings>  <add key="IsOpen" value= ""/> <add  key= " Android  "value=" "/></appsettings>

Connectionstring.config as follows:

<connectionStrings> <add name="defaultconnection"connectionstring="Data source= (LocalDb) \v11.0;initial catalog=aspnet-webapplication1-20140304225906;integrated
SECURITY=SSPI; attachdbfilename=| Datadirectory|\aspnet-webapplication1-20140304225906.mdf"ProviderName="System.Data.SqlClient"/> <add name="reportservertempdbconnectionstring"connectionstring="Data Source=.;i Nitial catalog=reportservertempdb;integrated security=true"ProviderName="System.Data.SqlClient"/> </connectionStrings>

Configsource in Web. config

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.