ASP.NET/IIS Problem when using ../../ in Application.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi. I have a virtual directory named Vehicles which serves a website. An
..aspx page in the Vehicles directory needs to display an image from a folder
existing one folder above Vehicles.

So I tried this. myImage.ImageURL = "../../image.gif"

And it's not working. Is this because when I use "../" it will only look
inside the Virtual Directory and not outside of it?

Thanks
 
...'s work at iis level, not file. so ../../image is the virtual
directory above your site. a common approach is to have a root vdir
called images then you just:

myImage.ImageURL = "/images/image.gif";

-- bruce (sqlwork.com)
 
If you are using an ASP control and not a HTML control then you can use the
"~" in your path instead of ".." like this:
myImage.ImageURL = "~/images/image.gif".

Using the ~ the path will resolve for you.

Regards,
Brian K. Williams
 
If you are using an ASP control and not a HTML control then you can use
the "~" in your path instead of ".." like this:
myImage.ImageURL = "~/images/image.gif".

Using the ~ the path will resolve for you.

But not in this particular case, obviously...
 
Chances are, IIS is configured to disallow "parent paths," which are
relative paths that lead to a parent directory. This is often (and by
default in IIS 6 and above) configured to prevent specific attacks that use
parent paths to access system directories outside the web site. Using
root-relative paths or virtual paths is your best bet.

--
HTH,

Kevin Spencer
Microsoft MVP

DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net
 
Thank you all for your help with this question!

Kevin Spencer said:
Chances are, IIS is configured to disallow "parent paths," which are
relative paths that lead to a parent directory. This is often (and by
default in IIS 6 and above) configured to prevent specific attacks that use
parent paths to access system directories outside the web site. Using
root-relative paths or virtual paths is your best bet.

--
HTH,

Kevin Spencer
Microsoft MVP

DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net
 
Back
Top