Monday, March 26, 2012

Site absolute paths?

I have a need for a site-absolute path specifier (server side).

My issue is that I have pages w/ graphics in the banners (whee!), but the pages
are at different levels of the folder hierarchy. Lastly, the entire site may
or may *not* be at the website root, it all depends on how it was installed.

So, to reference the graphics, I need a way to specify the location of the
graphic in a way that doesn't break.

Something like:

../images/pic1.jpg

obviously doesn't work if the page is a folder or two lower, and

/images/pic1.jpg

doesn't work if the site is installed in a sub-folder on the web server.

Is there some server-side tag that I can use in the path that will work like:

{site-root}/images/pic1.jpg

so that regardless of where the referencing page is located in the hierarchy
and regardless of where the site is installed, it will work?

Thanksusing the tilde ~ character might be just what you need..

here's an article about it..

http://www.awprofessional.com/artic...101145&seqNum=2
Julie wrote:
> I have a need for a site-absolute path specifier (server side).
> My issue is that I have pages w/ graphics in the banners (whee!), but the pages
> are at different levels of the folder hierarchy. Lastly, the entire site may
> or may *not* be at the website root, it all depends on how it was installed.
> So, to reference the graphics, I need a way to specify the location of the
> graphic in a way that doesn't break.
> Something like:
> ../images/pic1.jpg
> obviously doesn't work if the page is a folder or two lower, and
> /images/pic1.jpg
> doesn't work if the site is installed in a sub-folder on the web server.
> Is there some server-side tag that I can use in the path that will work like:
> {site-root}/images/pic1.jpg
> so that regardless of where the referencing page is located in the hierarchy
> and regardless of where the site is installed, it will work?
> Thanks

I guess I'm the only one that has ever had this problem? Regardless, I've
found a solution using the Application object:

ImageUrl = Application["AppPath"] + "/images/pic1.jpg"

0 comments:

Post a Comment