相对和绝对地址 [英] Relative and Absolute Address

查看:81
本文介绍了相对和绝对地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始在Web服务器根目录中位于
的生产Web服务器上进行维护工作。我把它移到了我的

本地Web服务器上的一个子网上,以便对它进行操作。我发现有一个包含引用图像的

文件:


< img src =" /images/Header.gif"


由于

绝对地址/ images,生产服务器上的正常工作因此而中断。我删除了绝对地址,并将

更改为相对图像。这在某些情况下有效,但不是全部,因为一些

的asp页面位于子文件夹中,并且都包含相同的包含文件。


我相信那里正在解决像〜/的问题。在.Net中可以查看网页

应用程序目录,但这似乎不适用于asp。有没有人用

a方式来处理来自Web应用程序级别的gif文件而不是web

服务器级别?

I recently began maintenance work on a production web server that is located
in the root directory of a web server. I moved this into a sub web on my
local web server in order to do work on it. I found that there is an include
file that references images:

<img src = "/images/Header.gif"

What worked correctly on the production server breaks on mine because of the
absolute address "/images". I removed the absolute address and changed that
to relative "images". This works in some cases but not in all because some
of the asp pages are in sub folders and all include the same include file.

I believe there is addressing like "~/" in .Net that would look in the web
application directory but this doesn''t seem to work in asp. Does anyone have
a way to address a gif file from the web application level and not the web
server level?

推荐答案

这已经(现在仍然)是IIS中引入的最愚蠢的行为,现在已经是我生命中的祸根了。我通常使用多种机制来查找对Web应用程序根目录(而不是站点)的正确

引用,并且*从不*使用root相对

url - 尤其是因为它破坏了进行本地服务器端调试的能力。


你将不得不深入挖掘并用相对引用或一些<替换所有这些引用br />
变量引用用需要的* real * url替换第一个''/'。


AFAIK没有简单的替换根网址中的'/''标识符。


Chris

" Nick K." <无**** @ bogus.com>在消息新闻中写道:e2 ************** @ TK2MSFTNGP10.phx.gbl ...

我最近开始在位于生产网络服务器上的维护工作

在Web服务器的根目录中。我把它移到了我的

本地Web服务器上的一个子网上,以便对它进行操作。我发现有一个包含引用图像的

文件:


< img src =" /images/Header.gif"


由于

绝对地址/ images,生产服务器上的正常工作因此而中断。我删除了绝对地址,并将

更改为相对图像。这在某些情况下有效,但不是全部,因为一些

的asp页面位于子文件夹中,并且都包含相同的包含文件。


我相信那里正在解决像〜/的问题。在.Net中可以查看网页

应用程序目录,但这似乎不适用于asp。有没有人用

a方式来处理来自Web应用程序级别的gif文件,而不是网页

服务器级别?

This has been (and still is) the most stupid behaviour ever introduced into IIS and it''s been the
bane of my life for some time now. I usually resort to a number of mechanisms to find the correct
reference to the root of the web application (as opposed to site) and *never* use root relative
url - not least of all because it breaks the capability to do local server-side debugging.

You''ll have to dig in and replace all those references with either relative references or some
variable reference that replaces the first ''/'' with the *real* url required.

AFAIK there isn''t a simplistic replacement to the root ''/'' identifier in a url.

Chris
"Nick K." <no****@bogus.com> wrote in message news:e2**************@TK2MSFTNGP10.phx.gbl...
I recently began maintenance work on a production web server that is located
in the root directory of a web server. I moved this into a sub web on my
local web server in order to do work on it. I found that there is an include
file that references images:

<img src = "/images/Header.gif"

What worked correctly on the production server breaks on mine because of the
absolute address "/images". I removed the absolute address and changed that
to relative "images". This works in some cases but not in all because some
of the asp pages are in sub folders and all include the same include file.

I believe there is addressing like "~/" in .Net that would look in the web
application directory but this doesn''t seem to work in asp. Does anyone have
a way to address a gif file from the web application level and not the web
server level?


当您说子网时,您的意思是虚拟目录吗?如果你标记为


Jeff


" Nick K." ; <无**** @ bogus.com>在消息中写道

新闻:e2 ************** @ TK2MSFTNGP10.phx.gbl ...
When you say "sub web", do you mean a virtual directory? This should work as
expected if you mark it as such

Jeff

"Nick K." <no****@bogus.com> wrote in message
news:e2**************@TK2MSFTNGP10.phx.gbl...
我最近开始维护工作在位于Web服务器根目录中的
的生产Web服务器上。我把它移到我的
本地Web服务器上的子网上,以便对它进行操作。我发现有一个
包含文件引用图像:

< img src =" /images/Header.gif"

什么工作正常由于
绝对地址/ images,生产服务器在我的中断。我删除了绝对地址并将
更改为相对图像。这在某些情况下有效但不是全部,因为某些asp页面位于子文件夹中,并且所有页面都包含相同的包含文件。

我认为有类似于〜/的解决方案;在.Net中可以查看web
应用程序目录,但这似乎不适用于asp。有没有人
有办法从Web应用程序级别而不是Web服务器级别处理gif文件?
I recently began maintenance work on a production web server that is located in the root directory of a web server. I moved this into a sub web on my
local web server in order to do work on it. I found that there is an include file that references images:

<img src = "/images/Header.gif"

What worked correctly on the production server breaks on mine because of the absolute address "/images". I removed the absolute address and changed that to relative "images". This works in some cases but not in all because some
of the asp pages are in sub folders and all include the same include file.

I believe there is addressing like "~/" in .Net that would look in the web
application directory but this doesn''t seem to work in asp. Does anyone have a way to address a gif file from the web application level and not the web
server level?



" Nick K."在消息新闻中写道:e2 ************** @ TK2MSFTNGP10.phx.gbl ...
:我最近开始在生产网络服务器上进行维护工作

位于

:在Web服务器的根目录中。我把它移到我的

:本地Web服务器上的子网上,以便对它进行操作。我发现有一个

包括

:参考图像的文件:



:< img src =" /images/Header.gif"



:在我的生产服务器上运行正常的是因为



:绝对地址/ images。我删除了绝对地址并将

改为

:改为相对图片。这在某些情况下有效但不是全部,因为一些

:asp页面在子文件夹中,并且都包含相同的包含文件。



:我相信有像〜/这样的解决方案。在.Net中可以看到网页

:应用程序目录,但这似乎不适用于asp。有没有人



:从网络应用程序级别而不是网络处理gif文件的方式

:服务器级别?


这是ASP还是HTML?


-

Roland Hall

/ *这些信息的分发是希望它有用,但

没有任何保证;甚至没有适销性的暗示保证

或特定用途的适用性。 * /

Technet脚本中心 - http:// www .microsoft.com / technet / scriptcenter /

WSH 5.6文档 - http://msdn.microsoft.com/downloads/list/webdev.asp

MSDN Library - http://msdn.microsoft.com/library/default.asp
"Nick K." wrote in message news:e2**************@TK2MSFTNGP10.phx.gbl...
: I recently began maintenance work on a production web server that is
located
: in the root directory of a web server. I moved this into a sub web on my
: local web server in order to do work on it. I found that there is an
include
: file that references images:
:
: <img src = "/images/Header.gif"
:
: What worked correctly on the production server breaks on mine because of
the
: absolute address "/images". I removed the absolute address and changed
that
: to relative "images". This works in some cases but not in all because some
: of the asp pages are in sub folders and all include the same include file.
:
: I believe there is addressing like "~/" in .Net that would look in the web
: application directory but this doesn''t seem to work in asp. Does anyone
have
: a way to address a gif file from the web application level and not the web
: server level?

Is this ASP or HTML?

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp


这篇关于相对和绝对地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆