如何跨多个 ASP.NET 站点集中 UI?

发布于 2024-07-24 13:14:31 字数 1009 浏览 1 评论 0原文

我在上一家公司担任 JSP/Struts 开发人员,负责的项目之一是一个主题标签库(作为共享库存在于每个 WebSphere 服务器上),该库允许公司中的任何 Java Web 开发人员引入任何标准只需最少的努力即可完成诸如内联网、公共等主题。 主题包括页眉、页脚、导航以及 CSS 和 HTML 链接。 当我们给他们选项时,他们甚至可以自定义一些东西,比如选择选定的选项卡。

这种设置非常理想,因为我们可以对任何标准 UI 元素进行集中更改,并且所有使用主题的网站都会自动引入这些元素,而无需网站开发人员进行任何工作。

随着 12 月份开始的新工作,我转而使用 ASP.NET。 我想在这里提出与主题应用程序类似的内容,因为我们正在运行一堆不同的网站,这些网站应该具有统一的外观和感觉。

实现这一目标的最佳方法是什么? 我宁愿不必重新编译任何内容来更新主题即可完成这项工作。

编辑:

虽然我希望得到更好的答案,但 .NET 诸神显然不同意我试图完成的任务。 以下是找到的三个选项:

  1. 将母版页编译为 DLL 并将其放入 GAC: 这在简单的情况下有效,但作为一种黑客手段,它太脆弱了。 我无法让它在我们的网站上正常工作。

  2. 在每个 Web 应用程序中创建一个指向母版页的虚拟目录:这实际上确实有效,尽管它并不能提供非常舒适的开发环境。 然而,我们试图摆脱的事情之一是必须在每个 Web 应用程序中创建虚拟目录。 没有骰子。

  3. 创建一堆自定义控件,将它们编译成DLL,然后将其放入GAC中:这是我选择的答案。 这是最不集中的选项,并且需要每个站点的开发人员做更多的工作,但这似乎是 Microsoft 祝福的唯一方法。

总之,我对 .NET 对此感到非常沮丧。 从总体上看,母版页只是代码,我看不出有任何理由不能轻松地集中它们以在多个 Web 应用程序中使用。 与JSP/Java相比,这似乎是一个重大损失。

One of the projects I was in charge of as a JSP/Struts developer at my last employer was a themes tag library (present on every WebSphere server as a shared library) that let any Java web dev in the company pull in any of the standard themes like intranet, public, etc. with minimal effort. The themes included header, footer, navigation, and links to css & javascript, etc. They could even customize things a bit when we gave them the option, like choosing a selected tab.

This setup was ideal because we could make centralized change to any standard UI elements and they were automatically pulled in by all sites using themes without any effort by the site developer.

With the new job I started in December, I've switched to using ASP.NET. I'd like to propose something similar in spirit to the themes app here, since we're running a bunch of different sites that should have a unified look and feel.

What's the best way to accomplish this? I'd rather not have to recompile anything to update the theme to make this work.

Edit:

Although I was hoping for a better answer, the .NET gods apparently don't approve of what I was trying to accomplish. Here are the three options that were found:

  1. Compile a Master Page into a DLL and put it into the GAC:
    This works in simple cases, but as a hack it's too brittle. I couldn't get it to work correctly with our site.

  2. Create a virtual directory to the Master Page in each web app: This actually does work, although it doesn't make for a very comfortable development environment. However, one of the things we are trying to move away from is having to create virtual directories inside each web application. No dice.

  3. Create a bunch of custom controls, compile them into a DLL, and put it into the GAC: This is the answer I selected. It's the least centralized option and requires more work for the developer of each site, but it seems to be the only Microsoft-blessed way.

In conclusion, I'm pretty frustrated with .NET over this. In the grand scheme of things Master pages are just code, and I don't see any reason why they couldn't be easily centralized for use in multiple web applications. This seems to be a major loss compared to JSP/Java.

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

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

发布评论

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

评论(1

思慕 2024-07-31 13:14:31

您可以将一些 UI 以自定义控件或服务器控件(如果不是 MVC 形式)的形式放入,然后将它们放入 GAC 中,从而进行分发。 该程序集中对控件的所有引用都将从 gac 中的最新版本中提取。 您还可以通过 Machine.config 执行操作,该配置在服务器级别而不是应用程序级别进行控制。

You can put some UI into the form of custom controls or server controls (if not in MVC) and then place them in the GAC thereby distributing them. All references to the controls in that assembly will be pulled from the latest version in the gac. You can also do things via the Machine.config which is controlled at the server level rather than the app level.

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