简体   繁体   English

在Default.aspx页上损坏的脚本和图像路径错误

[英]Script and image path errors broken on Default.aspx page

Simple aspx page, called Default.aspx. 简单的aspx页面,称为Default.aspx。 Images are broken and script files are not being found. 图像损坏并且找不到脚本文件。 I know these paths are correct because I can copy them to another aspx page that's not called Default.aspx and they work. 我知道这些路径是正确的,因为我可以将它们复制到另一个名为Default.aspx的aspx页面中并且它们可以工作。 I'm at a total loss, only thing I can think of is this has something to do with iis-express? 我完全不知所措,我唯一能想到的与iis-express有关吗? We recently moved from IIS 5.1, and this was working there. 我们最近从IIS 5.1迁移到了IIS 5.1。 Changing the script to /js/test.js seems to work but I don't understand why this is necessary. 将脚本更改为/js/test.js似乎可行,但是我不明白为什么这样做是必要的。 It doesn't help with the images. 它对图像没有帮助。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <title></title>
    <script language="JavaScript" src="js/test.js"></script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <img src="images/test.gif"/>
    </div>
    </form>
</body>
</html>

Assuming the following directory structure: 假设以下目录结构:

<root>
-js\
-images\
-default.aspx

try appending both paths with / to use absolute paths: 尝试在两个路径后都加上/以使用绝对路径:

<script language="JavaScript" src="/js/test.js"></script>

<img src="/images/test.gif"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM