如何在视图中获取 AppSettings?

How to get AppSettings in Views?

使用ServiceStack时如何在视图中使用IAppSettings取值?

我正在控制器和其他地方注入 IAppSettings,但如何访问视图代码中的值?

Razor 视图中的 AppSettings

AppSettings is a property of Razor's ViewPageBase 所以你可以简单地访问它:

base.AppSettings

AppSettings are First Class

您也不需要将 IAppSettings 注入容器,因为如果它尚未注册,ServiceStack 会自动为您在 IOC 中注册它。