多演示企业解决方案
我正在设计一个企业 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这可能会帮助您从传入请求中检测“租户”。
我不会动态选择不同的 MasterPage 文件,但 而是通过 Html 助手/父视图(或两者)将不同的内容渲染到 MasterPage。
This might help you with detecting the 'tenant' from the incoming request.
I would not dynamically select a different MasterPage file but rather render different content out to the MasterPage via Html Helpers / Patrial Views (or both).
很高兴看到您从这篇文章中得到一些用处。关于答案,我通常使用继承自system.web.ui.page的自定义页面类。在自定义页面类的 page_init 中,您可以设置母版页等。
类似(伪代码)的内容
然后,在您的页面中,继承自 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)
Then, in your pages, inherit from the MyCustomPage class instead of System.Web.UI.Page.
Good Luck