【发布时间】:2011-02-07 23:56:16
【问题描述】:
在将 ASP.NET Intranet 应用程序从 IIS6 迁移到 IIS7 时,我遇到了 html 标记中的绝对 url 的问题:我无法让他们将应用程序视为 url 的根,除非应用程序在网站的根目录。
这是一个演示问题的代码 sn-p。它发布在“默认网站”下的应用程序中。
前两个图像显示在浏览器中。第三个没有:
<body>
<form id="form1" runat="server">
Absolute path using asp image control:
<asp:Image ID="Image1" runat="server" ImageUrl="~/images/image.png" />
Relative path using html img tag:
<img alt="Works just fine" src="images/image.png" />
Absolute path using html img tag:
<img alt="WTF?" src="/images/image.png" />
</form>
</body>
在 localhost 上运行时,所有三个图像都能正常显示。
问题是“/images/image.png”在默认网站中查找名为“images”的目录,而不是在应用程序中。
有什么方法可以设置应用程序,使其根目录与 html url 的根目录相同?非常感谢您提供任何帮助!
- 克里斯
【问题讨论】: