vbscript - Server.Execute 使用固定路径
问题描述
我正在尝试server.execute()
通过虚拟函数库 ( <!-- #include virtual="lib/functions.asp"-->
) 中的包含来实现,我可以从系统中的任何子文件夹调用它。我正在尝试实现一个新功能,该功能应该存在于我们系统中的所有页面上,而将其手动添加到每个页面几乎是不可行的。而且我需要以一种不会干扰任何页面上的代码的方式实现它,这就是为什么我将它作为server.execute()
一个虚拟库来执行的原因,我知道它已经存在于系统中的任何地方。
例如:
'location of routine.asp = https://example.com/admin/routine/routine.asp
Server.Execute("routine/routine.asp")
'Will work if I add the virtual lib from an ASP-page in the admin subfolder, but not if I call it from another subfolder
Server.Execute("https://example.com/admin/routine/routine.asp")
'Does not work, because server.execute can't handle that kind of fixed path
文档明确指出不允许使用冒号和双斜杠,但我不知道如何确保文件的执行发生在系统中的哪个位置调用。
问题:如何使server.execute(path)
's path 处理固定路径,或动态更改路径以确保始终可以正确定位文件?
解决方案
如果您想使用绝对路径,请确保您使用的是绝对路径(从根目录开始的完整路径)。
认为您只需要明确指定绝对路径;
Server.Execute("/admin/routine/routine.asp")
推荐阅读
- java - 在 ArrayList 中找不到匹配项
从文件创建时 - c++ - 如何将鼠标双击添加到列表框
- javascript - 当树节点具有子树大小时,如何按索引返回树节点?
- python - 查找字符串中“单词”的位置并在字符串中“单词”之前和之后打印 N 个字符
- node.js - 如何使用 mongoose、node、在数组中查找 sum 对象
- swift - UIImage 的多个属性是否有更优雅的方法?
- firebase - Firebase - 防止恶意用户提取整个数据库
- react-native - TypeError: undefined is not an object (评估 '_reactNativeImagePicker.default.showImagePicker')
- flutter - Flutter Navigator pushAndRemove 帮助(未命名路由)
- java - 无法在 MySQL 中保存对象的 ArrayList - Hibernate/Spring Boot