(11) NetCore project reads the configuration file appsettings.json

1. Introduction


1. Reading configuration files is a very frequently used operation during development. The genus "can't write to death"

 

Second, NetCore reads the configuration file


 1. Create a new static public variable, which is called a singleton.

2. When the program Startup starts, pass the system variable to the singleton.

3. Add configuration information. The netcore configuration file is a standard json file, and children are read with: separated, please see the example.

4. Use a singleton to read the configuration content in the api.

 

The amount of code is small, and the map is directly attached, without the code.

 

 

 Add configuration section

 

 

 running result

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325296590&siteId=291194637