Asp.Net Core on Board: read configuration

Foreword

本文介绍Asp.Net Core 读取配置文件。

surroundings

1.Visual Studio 2017
2.Asp.Net Core 2.2 

Start

Preparatory

 
 
 
 
 
 
1.添加app.json文件并在里面添加内容;
2.将app.json文件配置到应用中;
3.添加app.json对应的AppConfig类; 4.下面三种方式读取配置文件皆在此基础上操作; 

Firsthand: Configuration reads

 
 
 
 

Second hand: Options mode read

 
 
 
 
 
 
Options模式使用依赖注入的方法直接将配置绑定到配置对象。

Third Hand: ServicesCollection reads

 
 
 
 
 
 
 
 
现在可以直接将需要的类注入到需要的地方,而不是像Options读取方式,在注入的地方需要IOptions<T>。

Outcome

本文介绍Asp.Net Core读取配置文件,下局介绍中间件,待续...

List



Author: home dotNET the
link: https: //www.jianshu.com/p/5c553ca61ed7
Source: Jane book
Jane book copyright reserved by the authors, are reproduced in any form, please contact the author to obtain authorization and indicate the source.

Guess you like

Origin www.cnblogs.com/Jeely/p/10959858.html