在同一代码库上部署多个站点 - Asp.Net、C#、MVC

发布于 2024-10-01 01:05:28 字数 543 浏览 1 评论 0原文

我最近继承了一个包含大约 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 技术交流群。

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

发布评论

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

评论(2

坦然微笑 2024-10-08 01:05:28

你的做法很好。

  1. 你应该使用主标记
  2. 你的网络系统将是CMS
  3. 你可以使用主题来定义不同项目的样式,或者你可以动态链接css文件(
  4. 如果它们确实是彼此的副本),而不是你可以通过将它们全部定义为一个来使其非常通用网站并将 css 图像标记的所有设置放入数据库中
  5. 如果您不想让所有内容变得非常通用,您可以制作 Web 用户控件并根据项目在运行时动态加载它们(记住,您可以加载 WebUserControls 在运行时使用 LoadControl 方法)

Your approach is good.

  1. You should use master markup
  2. Your web system will be CMS
  3. You can use themes to define styles of different projects or you can link css files dynamically
  4. if they are really copies of each other than you can make it very general by defining all of them as one website and put all the settings of css images markups in database
  5. If you don't want to make everything very generic you can make web user controls and load them dynamically at run time according to the project (Remember, you can load WebUserControls at runtime using the LoadControl method)
一页 2024-10-08 01:05:28

不幸的是,这个问题可能会得到“这取决于”的回答,因为每种方法都可以根据项目的需要使用或不使用。如果项目仅因演示文稿而异,那么母版页与 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.

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