ASP MVC 中的多租户
恐怕又是一个多租户帖子。 我只是找不到一个好的解决方案来解决我的问题,我已经阅读了有关 ASP MVC 多租户的所有精彩文章,但我仍然需要一些好的建议。
我将为我的一位客户创建一个企业形象。他们的公司结构就像一个主要公司(例如 Acme Group Ltd.),拥有其他几家公司(例如 Acme Holding Ltd、Acme Technology Ltd.、Acme Maritime Ltd. 等)。
我想使用一个 ASP MVC 项目作为所有站点的容器,以减少所需的代码并保持代码干燥。我还希望所有网站都使用相同的会员数据库。
我的第一个想法是为每个子公司创建一个控制器文件夹,为公司主页创建一个根控制器。然后它看起来像:
acme.com(“公司主页”)
acme.com/Holding(“Acme Holding Ltd.”)
acme.com/Maritme(“Acme Maritme 有限公司”)
...
这种结构对我来说很好,但我也希望网站的用户能够根据自己单独的域访问每个子网站,例如:
holding.acme.com(应定向至“acme.com/Holding”)。
...
这当然也可以,但问题是,当用户被定向到“acme.com/Holding”时,我不希望网址发生变化。我希望它仍然是“holding.acme.com”、“holding.acme.com/About”、“holding.acme.com/Contact”等,而不是“acme.com/Holding/Contact”等 ?
在这个特定项目中使用的最佳实践是什么,有什么想法吗
Yet another multi tenancy post im afraid.
I just cant find a good solution to my problem, I have read all the great posts on multi tenancy for ASP MVC but I still need some good advice.
Im going to create a corporate presence for one of my customers. Their company structure is like a main company (ex. Acme Group Ltd.) which own several other companies (ex. Acme Holding Ltd, Acme Technology Ltd., Acme Maritime Ltd., etc.).
I want to use one ASP MVC project to serve as the container for all the sites to cut down on the code needed and to keep it DRY. I also want all the sites to use the same Membership DB.
My first thought was to make one controller folder for each sub-company and one root controller for the corporate main page. Then it would look like:
acme.com ("Corporate main page")
acme.com/Holding ("Acme Holding Ltd.")
acme.com/Maritme ("Acme Maritme Ltd.")
...
This structure is fine by me, but I also want the users of the website to access each sub-site based on their own separate domains, ex:
holding.acme.com (This should direct to "acme.com/Holding").
...
That would of course also work, but the thing is that I do not want the url to change when the user is directed to "acme.com/Holding". I would like it to still be "holding.acme.com", "holding.acme.com/About", "holding.acme.com/Contact", etc. instead of "acme.com/Holding/Contact", etc.
What would be the best practice to use in this particular project, any thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
保持简单,使用 IIS URL 重写模块。您可以将其设置为将
acme-holding.com/*
URL 重写为acme.com/Holding/*
:Keep it simple, use IIS URL Rewrite Module. You can set it up to rewrite
acme-holding.com/*
URLs toacme.com/Holding/*
:我写了一篇关于多租户的博客,其中涵盖了您在这里尝试的内容。:
http://jasonjano.wordpress.com/2010/02/22/multi-presentation-websites-for-c/
祝你好运!
I wrote a blog on multi-tenancy that covers exactly what you are attempting here.:
http://jasonjano.wordpress.com/2010/02/22/multi-presentation-websites-for-c/
Good luck!