【发布时间】:2016-01-25 09:59:30
【问题描述】:
我使用下面的代码来读取配置。此代码用于 global.asax Application_Start 方法中。
var showAllMethodSetting = ConfigurationManager.AppSettings["ShowAllMethodsInSwaggerDocs"];
bool showAllMethods;
if (!bool.TryParse(showAllMethodSetting, out showAllMethods) || !showAllMethods)
{
... code ...
}
它在我的本地配置 (appSetting.config) 中运行良好,但是当我将代码推送到 Azure 时。它不起作用。
Entry ShowAllMethodsInSwaggerDocs 在 Azure 面板中可见,具有适当的值(我在 *.csdef 和 *.cscfg 中添加了节点),但未使用此值。为什么?也许我应该使用 ConfigurationManager 以外的其他类?
【问题讨论】:
-
您是否在应用部署后添加了门户设置,并且应用设置和门户设置使用相同的名称?
-
你可能想考虑一个抽象这个的库 - github.com/aloneguid/config
标签: c# .net azure asp.net-web-api configuration