Orchard CMS模块web.config

时间:2011-12-16 14:57:25

标签: orchardcms

我有一个现有的MVC 3 Web应用程序,我将其作为Orchard CMS中的模块运行。我对web应用程序的主要web.config有一整套appSettings,connectionStrings,system.serviceModel和其他各个部分。

在我看来,这些设置中的大多数(如果不是全部)都被忽略了。

显然,一个解决方案是使用我的设置更新Orchard.Web web.config,但我不希望尽可能自定义此web.config以便将来轻松升级。

在我的Orchard模块MVC应用程序中使用我自己的web.config是否还有其他推荐的方法/最佳实践?

干杯。

2 个答案:

答案 0 :(得分: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;

答案 1 :(得分:0)

是的,web.config的问题在于它不是租户意识的。在Orchard中处理设置的推荐方法是在站点内容类型中添加部件。整个代码中有很多例子。

这应该会为您提供更多信息:http://docs.orchardproject.net/Documentation/Adding-custom-settings