Groups | Blog | Home
all groups > asp.net > july 2004 >

asp.net : Relative URL


Alan Roberts
7/24/2004 9:00:17 PM
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


Saber
7/25/2004 2:10:38 AM
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.


[quoted text, click to view]

Bob Lehmann
7/25/2004 3:31:45 AM
Use "~". ~/images/image1.gif

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

Bob Lehmann

[quoted text, click to view]

Alan Roberts
7/25/2004 9:15:50 AM
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

[quoted text, click to view]


Alan Roberts
7/28/2004 9:42:17 PM
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

[quoted text, click to view]


AddThis Social Bookmark Button