【发布时间】:2015-11-22 06:52:33
【问题描述】:
[TL;DR]:如何在不使用 MVC 6 中的依赖注入的情况下访问 AppSettings 数据?
我正在尝试从我的 MVC 6 应用中的 _Layout.cshtml 获取一些应用设置数据。
我了解(并已实现)http://docs.asp.net/en/latest/fundamentals/configuration.html#using-options-and-configuration-objects 中描述的“选项”模式。
当我需要将一些设置注入特定控制器时效果很好,但我不太清楚如何将选项注入共享的 _Layout.cshtml,因为它没有关联的控制器。
有没有办法在不使用 DI 的情况下访问配置数据?
【问题讨论】:
标签: asp.net-mvc razor asp.net-core asp.net-core-mvc