.NET Core
First we create an empty ASP.Net Core Web Application
After you create the success we can see the startup files and configuration files
After the start in order to read the configuration, we will definitely have to be written in a configuration which, first of all,
The first step, write two kinds of format in the configuration appsettings.json :( write according to their needs)
Step Two: Get value configuration
In Program.cs operation:
New CoinAppSettings categories:
Tip: IConfigurationRoot to be quoted: using Microsoft.Extensions.Configuration;
Model also need to create a new entity:
The third step: the value of the configuration display, operate Startup.cs
Finally, if error, it may be in some places no references, you can reference it prompts to operate, should be no problem, we can get after running successfully:
This is a relatively common method, there is a simple principle for testing:
Step 1: Program.cs inside the operation, and the difference is no need to obtain a little above this value
Step Two: Startup.cs directly inside the injection, then the value can be directly obtained directly result
If you do not know what, you can leave a message, you can also Baidu closer look, some places might not have talked about, I hope you can put forward, we hope to grow and become an excellent architect