. NetCore ~ Json replaces Xml,. netcorejsonxml
In progress. in the era of netCore, the biggest change is that the use of Json is more active, basically replacing the previous XML, such as some user configurations, system configurations, and bag configurations are based on json, web. the config file is basically a zombie, just like the emperor of the Qing dynasty! Next, let's talk about several major json files and share with you the Empress Dowager Cixi!
Project. json project configuration file
It stores global configuration information of projects, such as nuget package dependencies,. netCore versions, and website release configurations.
Appsettings. json custom configuration file
It mainly stores users' personalized configurations in projects, such as database connection strings, log configurations, persistence methods, and third-party payment. In short, it takes out the contents of the deleetting node in web. config.
Bundleconfig. json front-end js/css package file
Package the js, css, and other files required by the website in this file, and then automatically load the files after the project is started.
ConfigConstants. json uncle framework global configuration file
It mainly includes system-level configuration items required by the linkcore framework, such as logs, redis connections, mongodb connections, ioc containers, cache policies, message policies, and so on.
These json files can be injected in startup, so that the configuration content in the json file can be used in the program.
public Startup(IHostingEnvironment env) { var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .AddEnvironmentVariables(); Configuration = builder.Build(); }
Through the above four large json files, you should have an intuitive understanding of the Json configuration advocated by netCore. In future articles, we will also introduce the implementation of relevant details.
Thank you for reading this article!