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

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
 
B

bruce barker

...'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)
 
B

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.

Regards,
Brian K. Williams
 
M

Mark Rae [MVP]

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...
 
K

Kevin Spencer

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
 
G

Guest

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top