我在 ASP.NET 4 下使用 URL 重写(使用 ISAPI_Rewrite),我发现我的一些图像没有加载,因为 .NET 似乎不理解我使用的是 html BASE 标记(非常标准且必不可少在进行 URL 重写时):
例如,在我的开发环境中,我有:
<base href='http://localhost/venuefinder/Website/'></base>
在我的页面上,我有:
<asp:ImageButton runat="server" ImageUrl="~/images/button.gif" />
在网站的主页(http://localhost/venuefinder/Website/)上这工作正常,但是在使用 URL 重写的页面上,图像不起作用:
/venuefinder/Website/venues/ashton_gate_stadium/V18639/
..因为浏览器正在尝试加载:
http://localhost/images/buttons/search-button.gif
代替:
http://localhost/venuefinder/Website/venues/images/buttons/search-button.gif
发生这种情况是因为 .NET 将按钮呈现为:
src="../../../images/buttons/search-button.gif"
...这是不正确的。
有什么办法可以纠正这个问题,以便 .NET 为图像呈现正确的 src 属性?(没有所有 ../../../ 等)