Absolute or Relative path?

Discussion in 'ASP .Net' started by matthias s., Jul 7, 2005.

  1. matthias s.

    matthias s. Guest

    Hi there,

    Say I have a domain called www.mydomain.com. In my virtual directory I've
    created subfolders called 'sub1' and 'sub2'. Now in 'sub1 resides the file
    'file1.aspx' and in 'sub2' resides the image 'img1.jpg'. When specifying a
    relative URL (to the image) in the file1.aspx I'd go like:

    <img src="../sub2/img1.jpg" />

    and should be fine with it. My problem is, I have a couple of web-controls
    within a 'controls' subdirectory which I use throughout the site. The aspx
    pages are located in different nested subdirectories. One of the controls
    which is hosted on almost every page links to an image. Due to the different
    'levels' at which the aspx page might be, the image is not displayed
    sometimes.

    I can't use absolute path values since server names might vary. There are
    dusty and vague memories of specifying relative path like this

    <img src="/sub2/img1.jpg" />
    or
    <img src="~/sub2/img1.jpg" />

    but neither yields the desired results. How do you do this?

    Thanks in advance!

    /matthias
     
    matthias s., Jul 7, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andreas Zita

    Absolute url from relative path

    Andreas Zita, Dec 31, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    29,589
    bharathmr
    Apr 29, 2008
  2. Matt
    Replies:
    3
    Views:
    19,569
    Sudsy
    Jul 8, 2004
  3. Thomas Guettler
    Replies:
    3
    Views:
    761
    Andrei
    Oct 27, 2003
  4. Nigel Wilkinson
    Replies:
    2
    Views:
    389
    Nigel Wilkinson
    Jul 25, 2005
  5. James Byrne
    Replies:
    3
    Views:
    565
    James Byrne
    Sep 14, 2010
Loading...

Share This Page