在 ISAPI 过滤器中,什么服务器变量为我提供虚拟目录的物理路径?
如果我在 IIS 管理器中定义了一个“应用程序”,我可以获取服务器变量 APPL_MD_PATH 的值来检索与该应用程序关联的物理路径。
如果我配置了“虚拟目录”,APPL_MD_PATH
仍然为我提供与应用程序关联的物理路径,而不是与虚拟目录关联的物理路径。
如何检索与当前请求关联的虚拟目录的物理路径?
如何确定请求是由应用程序还是虚拟目录提供?
If I have an "application" defined in IIS Manager, I can get the value of the server variable APPL_MD_PATH
to retrieve the physical path associated to the application.
If I have a "virtual directory" configured, APPL_MD_PATH
still gives me the physical path associated to the application, not the physical path associated to the virtual directory.
How can I retrieve the physical path to the virtual directory to which the current request is associated?
How can I determine whether the request is being served from an application versus a virtual directory?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
HSE_REQ_MAP_URL_TO_PATH_EX
查找任何 URL 的物理路径。如果您想知道自己是否位于虚拟目录中,只需一次剥离最右边的一段即可开始遍历 URL。调用
HSE_REQ_MAP_URL_TO_PATH_EX
直到您 a)击中应用程序根目录或 b) 击中与前一个具有不同前缀的物理目录。如果 (b) 则您位于虚拟目录中。您也可以使用上面的方法来查找当前vdir的物理路径。
You can use
HSE_REQ_MAP_URL_TO_PATH_EX
to find the physical path of any URL.If you want to tell whether you are in a vdir or not, simply start walking up the URL by stripping off one rightmost segment at a time. Call
HSE_REQ_MAP_URL_TO_PATH_EX
until you either a) hit the application root or b) hit a physical directory which has a different prefix than the previous one. If (b) then you are in a virtual directory.You can also use the approach above to find the physical path of the current vdir.