3
考虑到与下面的结构的Web应用程序:为什么嵌套的ASP.NET 4.0 web.config偶尔会停止继承?
Main Site (/)
web.config (root; appSetting="rootSetting")
Applications (/Applications)
App1 (/Applications/App1)
web.config (app1; appSetting="app1Setting")
在应用程序内,大多数时候我可以同时获得“rootSetting”和经由WebConfigurationManager.AppSettings的“app1Setting” []和WebConfigurationManager.ConnectionStrings [ ]静态索引器。
但是,有时会出现App1的web.config未加载。发生这种情况时,我可以得到“rootSetting”,但“app1Setting”返回null。
我在Windows Server 2008 R2/IIS7.5/ManagedPipelineMode = Classic下运行。
Thx @retrodrone,我去使用WebConfigurationManager.OpenWebConfiguration(路径)来确切地指定我想打开哪个web.config。 – Jason