Asp.Net Core 配置文件
2019-08-03 15:44
1381 查看
一 创建ConfigurationManager类
public class ConfigurationManager { public readonly static IConfiguration Configuration; static ConfigurationManager() { Configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json", optional: true).Build(); } }
二 控制器内读取方式
public class HomeController : Controller { public IActionResult Index() { //读取 string str=ConfigurationManager.Configuration["Logging:LogLevel:Default"]; return View(); } }
相关文章推荐
- 【无私分享:ASP.NET CORE 项目实战(第八章)】读取配置文件(二) 读取自定义配置文件
- 2.2Bind建立配置文件和实体的映射「深入浅出ASP.NET Core系列」
- Asp.net Core中使用Redis 来保存Session, 读取配置文件
- ASP.NET CORE入门之读取Json配置文件
- ASP.NET Core开发-读取配置文件Configuration
- asp.net core 如何在Controller获取配置文件的值
- ASP.NET Core实现类库项目读取配置文件
- asp.net core配置文件加载过程的深入了解
- ASP.NET CORE入门之读取Json配置文件
- Asp.Net Core轻松学习系列之配置文件
- asp.net core2.0中网站发布的时候,怎么样才配置才可以使视图文件不被打包进去?
- asp.net core 将配置文件配置迁移到数据库(一)
- asp.net core1.x/asp.net core2.0中如何加载多个配置文件
- ASP.NET Core 2.0系列学习笔记-NLog日志配置文件
- 【无私分享:ASP.NET CORE 项目实战(第八章)】读取配置文件(二) 读取自定义配置文件
- ASP.NET Core开发-读取配置文件Configuration
- 2.2Bind建立配置文件和实体的映射「深入浅出ASP.NET Core系列」
- asp.net core-6.Bind读取配置文件到C#实例中
- ASP.NET Core 配置文件(无处不在的依赖注入)
- ASP.NET Core 2.0系列学习笔记-配置文件