While migrating ASP.NET intranet applications from IIS6 to IIS7, I came across a problem with absolute urls in html tags: I can't get them to consider the application as the root of the url unless the application is published at the root of the web site.
Here is a code snippet that demonstrates the problem. It is published in an application under the "Default Web Site."
The first two images display in the browser. The third does not:
<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>
All three images display properly when run on localhost.
The problem is that "/images/image.png" is looking for a directory called "images" in Default Web Site, not in the application.
Is there any way to set up the application so it's root is the same as the root for html urls? Any help with this is greatly appreciated!
- Chris