referencing images with full path such as /images/header/left.gif
When creating a web project, VS2002-2003, the default is to create a virtual application root off your existing IIS. So your are testing your web application, you load URL as follows:
http://localhost/AppName/homepage.aspx
The problem resides when referencing global images; I have a designer work on a template and since the template can be loaded or used anywhere throughout the site (nested directories), the src= for these images must be absolute for the loading to be transparent:
<img src="/images/spacers/white_dot.gif">
I know I have the option to convert the image tag to runat="server" and made the src as = "~/images/spacers/white_dot.gif">....but to do this with all the designer image tags is quite tedious and to ask the designer to do it is also tedius. Furthermore, on other image tags such as <td runat="server" background="~/images/..." this will not work and ASP.NET will simply ignore the "~" and render the tag as <td background="~/images/...>
So, building applications intended to be hosted on URLs such as:
http://www.XYZ.com
with default development URLs such as:
http://localhost/XYZ/
turns out to be problematic either at design or at deployment.
The various solutions I have found are as follows and I am wondering if there is yet a better way of handling this situation with VS 2005.
A - With VS2002 & VS2003, I would simply modify my IIS settings to point to a different wwwroot per website (or application) and develop against the default application (e.g.http://localhost ). I have been doing this so long now, I even created a small app to help me manage the IIS settings automatically with a click.
B - hardcode the image URL's with /AppName/images so I get a good design time experience, then process these pages with a build script removing the src="/AppName/images" prefix and leaving src="/images"
Other things attempted just in case.... however, this didn't work..and I honestly didn't expect it to work also.
A - using mapped URL's such as:
<urlMappings>
<addurl="~/images"mappedUrl="/images/"/>
</urlMappings>
IDEAL SOLUTION WITH VS2005
After some investigation, the ideal solution would be to put an option on the site properties specifying whether application should use default application or not. Since VS2005 has the built in web server instance using a random port number, this solution would be trivial to implement and the default application -- hence, the URL would behttp://localhost:1234/which would work great.

