Orchard CMS模块的web.config

3
我有一个现有的MVC 3 Web应用程序,我将其作为模块在Orchard CMS中运行。我的主Web应用程序的web.config有很多appSettings、connectionStrings、system.serviceModel和其他各种部分。
在我看来,大部分(如果不是全部)这些设置都被忽略了。
一个解决方案显然是更新Orchard.Web web.config以使用我的设置,但我尽可能不想自定义此web.config,以便未来易于升级。
在我的Orchard模块MVC应用程序中使用自己的web.config是否有其他推荐的方法/最佳实践?
干杯。
2个回答

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;

0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接