2011-12-16 191 views
3

我有一個現有的MVC 3 Web應用程序,我將它作爲Orchard CMS內的模塊運行。我的web應用程序的web.config主要有appSettings,connectionStrings,system.serviceModel和其他各個部分。Orchard CMS模塊web.config

它在我看來好像大多數(如果不是全部)這些設置被忽略。

一個解決方案顯然是更新Orchard.Web web.config與我的設置,但我不希望自定義此web.config儘可能允許將來輕鬆升級。

在我的Orchard模塊MVC應用程序中使用我自己的web.config是否還有其他建議的方法/最佳實踐?

乾杯。

回答

4

我找到了答案在這裏:http://blog.wouldbetheologian.com/2012/09/loading-module-specific-connection.html

// Read the connection string from the *local* web.config (not the root). 
var fileMap = new ExeConfigurationFileMap(); 
fileMap.ExeConfigFilename = HttpContext.Current.Server.MapPath("~/Modules/Alanta.Web.Corp/web.config"); 
var configuration = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None); 
_connectionString = configuration.ConnectionStrings.ConnectionStrings["AlantaEntities"].ConnectionString;