经典 ASP:复制应用程序时出现 URL 问题

发布于 2024-10-06 14:33:33 字数 563 浏览 3 评论 0原文

我有一个旧的经典 ASP 应用程序,我想并行复制它 - 也就是说,我想在原始应用程序旁边配置另一个副本(与不同的数据库通信)。

因此,在我拥有 //MyServer/MyApp1/ 的地方,我很快也会拥有 //MyServer/MyApp2/... 到目前为止一切顺利。

除了应用程序中的许多 URL 是绝对的(例如 JS 和 CSS 文件),例如 < /代码>。

我可以搜索对 /MyApp1/ 的引用并将其替换为 /MyApp2/,但这是一项烦人的任务,在更新核心应用程序时我必须重复该任务,并且如果想要创建其他副本 - 有可能,尽管是暂时的。

我可以将这些 URL 更改为父路径,但这意味着我需要以不同的方式引用每个资源,具体取决于我在应用程序文件夹结构中的位置。同样,它会起作用,但由于多种原因,我不喜欢使用父路径。

鉴于经典 ASP 中没有波形符 (~) 功能(指应用程序根目录),我可以考虑其他替代方案吗?

I have an old Classic ASP application that I want to duplicate in parallel - that is, I want to configure another copy (talking to a different database) alongside the original.

So where I have //MyServer/MyApp1/, I will also soon have //MyServer/MyApp2/... so far so good.

Except that many URLs in the app are absolute (for example JS and CSS files), e.g. <script type="text/javascript" src="/MyApp1/menu.js"></script>.

I could search for references to /MyApp1/ and replace it with /MyApp2/, but it's an annoying task that I will have to repeat as I update the core application, and in the event of wanting other copies creating - a likelihood albeit temporary.

I could change these URLs to parent paths, but this means I need to refer to each resource differently, depending on where in the application folder structure I am. Again, it would work, but I don't like using parent paths for a number of reasons.

Given that there is no tilde (~) feature in Classic ASP (to refer to the application root), are there any alternatives that I can consider?

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

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

发布评论

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

评论(2

南薇 2024-10-13 14:33:33

@CJM:我通常有一个db.asp,其中包含函数,它们作为主要包含处理打开/关闭数据库连接几乎在我的所有页面上。在此 db.asp 中,我将定义一个 appurlabsurl 路径,在您的情况下,该路径可能具有 /MyApp1,然后您可以在您的脚本。

第一次执行此操作时,这将是一个搜索/替换任务,但一旦完成,后续的“重复”项目将只需要更新一个变量。

@CJM: I usually have a db.asp which contains the functions and subs that handle opening/closing database connections as the primary include on practically all of my pages. In this db.asp I would then define a appurl or absurl path which could, in your case, have /MyApp1, and then you can use <script type="text/javascript" src="<%=appurl %>/menu.js"></script> in your scripts.

The first time you do it, it'll be a bit of a search/replace mission, but once it's done, subsequent "duplicate" projects will just need that one variable updated.

在经典 ASP 中,您可以使用 Server.MapPath("/") 获取根目录,或使用 Server.MapPath(".") 获取当前目录。

In Classic ASP, You can use Server.MapPath("/") to get the root directory, or Server.MapPath(".") to get the current directory.

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