如何在 ASP.NET 项目之间重用 html/js/服务器端代码?

发布于 2024-07-13 04:31:43 字数 824 浏览 4 评论 0原文

我们有一个博客系统,出售给许多不同的客户(包括在许多不同的项目中)。 该系统包括许多不同的文件 - 一些 aspx 页面、一两个 ascx 控件、一个 css 文件、一个 javascript 文件和一些 codebehind/vb.net 实用程序文件。 一般来说,该模块 90% 以上的内容在客户之间是相同的 - 但当然每个客户都希望进行一些定制 - 从装饰性 html/css 更改到服务器/客户端逻辑调整。

目前,要将我们的博客系统部署到新项目,我们只需复制文件(来自我们处理的上一个项目)并根据需要自定义文件......但现在我们有 10 个独特且不兼容的博客系统副本。 仅仅让博客系统在每个项目中运行就需要相当多的时间——并且将改进从新的博客系统传播到旧的系统和维护是一个真正令人头痛的事情。

理想情况下,我们应该有一个博客系统文件的“黄金副本”,可以满足一般(90%)的情况。 我们可以将黄金副本添加到新项目中,并使博客系统几乎立即运行 - 但是我们可以根据需要添加或自定义文件。 更好的是,当我们对“黄金副本”进行改进时,这些更改可以轻松部署到我们所有的站点,同时尊重我们为客户所做的定制。

我知道我们可以添加新的 css 文件来更改基类,并添加新的 vb.net 类来覆盖基本服务器端逻辑 - 但我真的不确定如何处理 aspx、ascx 和 js 文件。 理想情况下,我们可以找到基于文件或源安全的解决方案 - 例如,如果存在带有自定义项的新文件,它将自动覆盖黄金文件中任何相应的标记/js/等。当然,我们持开放态度对于所有解决方案 - 这似乎是一个非常常见的情况,所以我希望有人能够开发出“最佳实践”。 我所描述的可能吗? 非常感谢任何建议或指导 - 提前致谢!

谢恩

We have a blog system that we sold to a number of different customers (included in many different projects). This system includes a number of different files – a few aspx pages, one or two ascx controls, one css file, one javascript file and some codebehind/vb.net utility files. In general 90+% of this module is the same between customers – but of course every customer wants some customization – from cosmetic html/css changes to server/client logic tweaks.

Currently, to deploy our blog system to a new project we simply copy the files (from the last project we worked on) and customize the files as needed…but now we have 10 unique and incompatible copies of our blog system. Just getting the blog system working in each project takes a fair amount of time – and spreading the improvements from newer blog systems to older systems and maintenance is a real headache.

Ideally we would have a single “golden copy” of our blog system files that served the general (90%) case. We could add that golden copy to a new project and have a blog system working almost instantly – however we could then add or customize files as necessary. Even better – as we make improvements to the “golden copy” those changes can be easily deployed to all our sites – while honoring the customizations we have made for our customers.

I know we could add new css files to change base classes and add new vb.net classes that override base server side logic – but I’m really not sure how to handle aspx, ascx and js files. Ideally we could find a file based or source safe solution – for example if a new file is present with customizations it would automatically override any corresponding markup/js/etc in the golden file. Of course we are open to all solutions - this seems like a pretty common scenario so I was hoping someone would have developed a “best practice.” Is what I’m describing even possible? Any advice or direction is really appreciated – thanks in advance!

Shane

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

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

发布评论

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

评论(1

神经大条 2024-07-20 04:31:43

您可以使用源代码控制系统和 Visual Studio 来执行此操作,但如果您成功(许多客户),它可能会变得混乱。 如果你采用这种方法,我会这样做。

  1. 将代码分成2个结构
    或 Visual Studio 项目。 这
    通用代码(你提到的90%)
    和定制代码(其他
    10%).

  2. 创建一个初始结构或
    你的基线
    源控制系统。 这是
    两个代码的最通用版本
    集。

  3. 对自定义部分进行分支
    每个客户端的代码。

  4. 当以下情况时,对公共代码部分进行分支:
    您有错误修复或其他更新。
    在 Visual Studio 中您可以
    创建 1 个项目并合并
    目录或使用 2 个不同的
    项目合并在一个解决方案下。

希望有帮助。

You could use your source control system and Visual Studio to do this, but it could get messy if your successful (many clients). If you took this approach, here’s how I would do it.

  1. Separate the code into 2 structures
    or Visual Studio projects. The
    common code (the 90% you mention)
    and the customized code (the other
    10%).

  2. Create an initial structure or
    baseline in your
    source control system. This is the
    most generic version of the two code
    sets.

  3. Branch the customized portion
    of the code for each client.

  4. Branch the common code portion when
    you have bug fixes or other updates.
    Within Visual Studio you could
    either create 1 project and merge
    the directories or use 2 different
    projects combined under one solution.

Hope that helps.

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