Official Document: HREF
In the old version of ASP, the global configuration of the project usually exists in the AppSettings of the Web. config, and it is only possible to use the configurationmanager.appsettings["foo" to take the variable named Foo. in ASP. NET core, the way to access the configuration file has changed a lot. However, the Web. config in ASP. NET core has been replaced by Appsettings.json, plus a lot of dependency injection (Dependency injection) in ASP., which makes the read configuration information different from before. The new framework takes a more flexible and extensible configuration. Official use: Options. Configurationextensions
First the NuGet package is introduced
Microsoft.Extensions.Options.ConfigurationExtensions
How to quote is Emmmm
Or:
Then add the custom data to the Appsettings.json file
Create a corresponding model
Then configure the Startup.cs in the
// ADD functionality to inject ioptions<t> Services. AddOptions (); Services. Configure<AppSettings> (configuration.getsection ("AppSettings"));
Then, you can use it where you want to use it.
It's already been shown.
. NET core Read Appsettings.json configuration