Orchard CMS 模块 web.config

发布于 2024-12-21 16:58:52 字数 344 浏览 1 评论 0原文

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

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

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

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

干杯。

I have an existing MVC 3 web application and i'm running it as a module inside Orchard CMS. My main web.config for the web app has a whole load of appSettings, connectionStrings, system.serviceModel and various other sections.

It looks to me as though the majority (if not all) of these settings are being ignored.

One solution would obviously be to update the Orchard.Web web.config with my settings, but i would prefer not to customise this web.config as far as possible to allow easy upgrade in future.

Are there any other recommended methods / best practices for using my own web.config within my Orchard module MVC app?

Cheers.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

单调的奢华 2024-12-28 16:58:52

我在这里找到了答案: 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;

I found an answer here: 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;
木槿暧夏七纪年 2024-12-28 16:58:52

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

这应该为您提供更多信息: http://docs.orchardproject.net/Documentation/Adding -自定义设置

Yes, the problem with web.config is that it is not tenant-aware. The recommended way of treating settings in Orchard is to add parts to the Site content type. There are quite a few examples of that throughout the code.

This should give you some more info: http://docs.orchardproject.net/Documentation/Adding-custom-settings

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文