多演示企业解决方案

发布于 2024-09-26 04:19:56 字数 946 浏览 5 评论 0原文

我正在设计一个企业 Web 应用程序,该应用程序将具有单一代码库和单一数据库(不需要基于租户的数据库的任何灵活性),但基于客户的不同演示。我们可能有 3 到 4 个不同的客户端(网站),使用相同的核心逻辑和框架,但客户端特定的页眉、页脚、图像、CSS 等。我需要一个多演示解决方案,然后是一个成熟的多租户。我在网上看到的大多数示例都是针对成熟的多租户,我认为我不需要那么复杂的东西。我在这里找到了一些对我的情况非常有用的信息:

http://jasonjano.wordpress.com/2010/02/22/multi-presentation-websites-for-c/

正如上面链接中所建议的,我能够根据根据我的 web.config 文件中的以下配置请求域:

<configuration>
    <appSettings>
        <add key="MySite1.MyDomain.com" value="1"/>
        <add key="www.MySite1.MyDomain.com" value="1"/>
        <add key="MySite2.MyDomain.com" value="2"/>
        <add key="localhost" value="1"/>
    </appSettings>
</configuration>

此后,如何根据 ID 动态选择我的母版页、图像和 css 文件?另外,我将从数据库填充“CustomAppSettings”类(如文章中所建议的),是否建议将其设为静态以便可以在不同层中访问它?否则推荐的方式是什么?

非常感谢您的建议。

I am working on designing an enterprise web application which will have single codebase and single database (don't need any flexibility in database based on tenants) but different presentations based on clients. We might have 3 to 4 different clients (websites) utilizing same core logic and skeleton but client specific headers, footers, images, css etc. I need a multi-presentation solution then a full fledge multi-tenancy. Most of the samples I saw online are geared towards full fledged multi-tenancy I don't think I need that complicated stuff. I found some information here which is very useful in my case:

http://jasonjano.wordpress.com/2010/02/22/multi-presentation-websites-for-c/

As suggested in above link, I am able to identify and grab a unique ID based on the domain requested as per below configuration in my web.config file:

<configuration>
    <appSettings>
        <add key="MySite1.MyDomain.com" value="1"/>
        <add key="www.MySite1.MyDomain.com" value="1"/>
        <add key="MySite2.MyDomain.com" value="2"/>
        <add key="localhost" value="1"/>
    </appSettings>
</configuration>

After this, how do I dynamically select my Master page, images and css files based on the ID? Also I will be populating "CustomAppSettings" class (as suggested in article) from database, Is it advisable to make it static to it can be accessed in different layers? otherwise what is the recommended way?

Your suggestions would be very much appreciated.

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

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

发布评论

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

评论(2

清引 2024-10-03 04:19:56

很高兴看到您从这篇文章中得到一些用处。关于答案,我通常使用继承自system.web.ui.page的自定义页面类。在自定义页面类的 page_init 中,您可以设置母版页等。

类似(伪代码)的内容

class MyCustomPage : System.Web.UI.Page
{
public void Page_Init(object sender, eventargs e) {
this.MasterPageFile = CurrentSettings.MasterPageFile <Or however you are getting your masterpage file>
}

然后,在您的页面中,继承自 MyCustomPage 类而不是 System.Web.UI.Page。

祝你好运

Glad to see you are getting some use out of that article. Regarding the answer, I usually use a custom page class that inherits from system.web.ui.page. In the page_init of the custom page class you can set the master page, etc..

Something like (psuedo code)

class MyCustomPage : System.Web.UI.Page
{
public void Page_Init(object sender, eventargs e) {
this.MasterPageFile = CurrentSettings.MasterPageFile <Or however you are getting your masterpage file>
}

Then, in your pages, inherit from the MyCustomPage class instead of System.Web.UI.Page.

Good Luck

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