2011-12-16 189 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;