Web. config User Guide, web. config Guide
<ConnectionStrings configSource = "db. config"/>
External file db. config:
Copy codeThe Code is 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 =.; Initial Catalog = ReportServerTempDB; Integrated Security = True"
ProviderName = "System. Data. SqlClient"/>
</ConnectionStrings>
Specific format
<Node name configSource = "configuration file path"/>
Notes
1. if configSource is specified, the external files shall prevail. the node configuration under connectionStrings in config is invalid, even if the web. the connection string nodes under connectionStrings in config are invalid if they are not deleted.
2. The root node of the external file must be the same as the node specified in web. config (in fact, the node configuration is moved to the external file)
3. One node can only specify one external configuration file. You cannot specify the external files of multiple nodes as the same. For example, you cannot specify the configSource of connectionStrings and appSettings as the same file.
Node Data Acquisition
ConfigurationManager. GetSection ("node name"); // a Node object is returned.
Hypothetical: After the setup, ASP. NET5 is cross-platform and json is used as the configuration file. It can also be implemented!
The above is all the content of this article. I hope you will like it.