在同一代码库上部署多个站点 - Asp.Net、C#、MVC
我最近继承了一个包含大约 10 个项目的解决方案。其中 6 个项目是个人网站,基本上是原始网站的复制/粘贴。
这意味着必须对每个项目进行任何需要进行的更改才能更新所有网站。
我想要做的是为网站代码建立一个项目,并能够部署该代码和一些配置设置来创建一个新网站。这样,当我对主 Web 项目进行更新时,我可以将其部署到所有网站。
人们通常如何处理这个问题?我将概述我对此的想法,希望你们中的一些人能够指出实现这一目标的更好方法,或者至少给我一些肯定,证明我走在正确的轨道上。
- 拥有非常通用的容器的主标记。
- 允许设置站点的用户/人员向站点添加小部件,这些小部件将分配给所有通用容器顶部和底部的小部件占位符。
- 所有样式和颜色都将通过可交换的样式表进行控制。
- 我知道你可以做某种主题。这是否只是交换 css 组并让您配置在 webconfig 中使用哪一组?
- 对于在所有网站上都相同的元素(例如页脚图像),有一个命名约定。因此,如果我希望站点 A 有一些页脚图像,我只需在部署时替换项目中的 footer.jpg 即可。
I recently inherited a solution with about 10 projects in it. 6 of these projects are individual websites that are basically copy/pastes of the original.
This means that any changes that need to be made must be made to each project in order to update all the websites.
What I want to do is have one project for the website code and be able to deploy that code and some configuration settings to create a new website. That way when I make updates to the main Web project I can just deploy to all the websites.
How do people normally approach this? I'll outline my thoughts on it and hopefully some of you can point out better ways to accomplish this or at least give me some affirmation that I am on the right track.
- Have a master markup with very general containers.
- Allow the users/people setting up the site add widgets to the site which will be assigned to widget placeholders at the top and bottom of all the generic containers.
- All styling and colors will be controlled with a stylesheet that can be swapped out.
- I know there is some kind of theming you can do. Does this just swap out groups of css and let you configure which one to use in the webconfig?
- For elements that will be the same across all sites such as footer images have a naming convention. So if I want Site A to have some footer image I just replace the footer.jpg in the project when I deploy.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你的做法很好。
WebUserControls
在运行时使用LoadControl
方法)Your approach is good.
WebUserControls
at runtime using theLoadControl
method)不幸的是,这个问题可能会得到“这取决于”的回答,因为每种方法都可以根据项目的需要使用或不使用。如果项目仅因演示文稿而异,那么母版页与 CSS 相结合将是一个合理的解决方案。
That's unfortunately a question that is likely to get the response 'It depends' as each of those approaches could be used or not used dependent on the needs of the project. If the projects only vary by presentation then master pages combined with CSS would make a reasonable solution.