Relative URL

  • Thread starter Thread starter Alan Roberts
  • Start date Start date
A

Alan Roberts

Hi

How do I refernece links so that they work on both my development and live
servers? On my development machine, my web site exists in a virtual
directory so a relative link such as '/images/image1.gif' that works on my
live server doesn't work (because it points back to the root of my website,
not that of my virtual directory)?

Cheers

Alan
 
It works for me both in server-side and my IIS on pc:
<img src='images/image1.gif'>
remove the first "/" and try again, if you've images folder in one level
upper than your files, it works.

Another thing, perhaps you didn't added the file to your project.
if you use visual studio:
select your "images" folder in solotion explorer, right-click|Add|Existing
Item , and then choose your images you want to add to yout project.
 
Hi Saber

Thanks for the advice but this doesn't work for controls etc. I have a
number of controls that use graphics. These controls can occurr on pages at
any level within my site so the relative path to the images folder from them
is different. I need some way to indicate paths relative to the application
root rather than the web server route.

Cheers

Alan
 
Use "~". ~/images/image1.gif

You will have to use server tags though. Or perhaps the ResolveURL method.

Bob Lehmann
 
Thanks guys. This seems to work got img tags as well as long as i include
runat=server in them. Is there a similar shortcut that can use within CSS
files?

Alan
 
Back
Top