473,407 Members | 2,320 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Absolute Pathing Challenge

Hi All,
I got a challenge to make the same APS/Script/Html run on different web
roots. I can not use relative pathing in a lot of cases. We use lots of
included files so depending on where that file is running, the pathing in
those included files varies. So we do a lot of absolute pathing.
Example: Instead of Mappath("../../../_scripts/menu/mymenuscript.js") we use
mappath("/_scripts/menu/mymenuscript.js").

In one case, the code is loaded right on wwwroot with all the folders off of
wwwroot.
So a path like so mappath("/_scripts/menu/mymenuscript.js") would return
c:\inetpub\wwwroot\_scripts\menu\mymenuscript.js

In another case, the SAME code has to run under a subweb, so we would have
to include the subweb name like so.
mappath("/MySubWeb/_scripts/menu/mymenuscript.js") would return
c:\inetpub\wwwroot\MySubWeb\_scripts\menu\mymenusc ript.js

So how do you solve this.
With ASP pages, I could detect where I'm running in the global.asa and set a
APP variable and use that variable anywhere I'm building a path name. I
would have to modify all the HTML code etc <A
HREF='<%Application("BasePath")%>/myfolder/mywebpage.htm'>MyLink</A>
This is a pain...but doable. But that does not address a lot of the pure
HTML files or included script files in the ASP pages or Included ASP files..

Examples:
How would I change an ASP include file.
<!--#INCLUDE Virtual ="/Includes/MyAsp.asp" -->

Or a JScript include like this
<script type="text/javascript" language="javascript"
src="/_scripts/MainMenu/MyMenuScripts.js"></script>

Then there is the issue of the client side JScript having to know that
pathing info which could be in a included file like the example above.

Looking for some ideas...examples would be great too.

Thanks
Stuart



Jul 19 '05 #1
9 3684
"Stuart" <st***********@insurity.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi All,
I got a challenge to make the same APS/Script/Html run on different web
roots. I can not use relative pathing in a lot of cases. We use lots of
included files so depending on where that file is running, the pathing in
those included files varies. So we do a lot of absolute pathing.
Example: Instead of Mappath("../../../_scripts/menu/mymenuscript.js") we use mappath("/_scripts/menu/mymenuscript.js").
Note, that is a relative path, NOT an absolute path. It is relative to the
root of the webserver (as specified by the leading /).
In one case, the code is loaded right on wwwroot with all the folders off of wwwroot.
So a path like so mappath("/_scripts/menu/mymenuscript.js") would return
c:\inetpub\wwwroot\_scripts\menu\mymenuscript.js

In another case, the SAME code has to run under a subweb, so we would have
to include the subweb name like so.
mappath("/MySubWeb/_scripts/menu/mymenuscript.js") would return
c:\inetpub\wwwroot\MySubWeb\_scripts\menu\mymenusc ript.js
I'm not sure what exactly it is you are asking for? Is there a file at this
location?
c:\inetpub\wwwroot\MySubWeb\_scripts\menu\mymenusc ript.js
If so, then you don't need to do anything. Your ASP looks correct.

Or do you want this to also point to:
c:\inetpub\wwwroot\_scripts\menu\mymenuscript.js

In that case, you must not include the sub folder name in the path. This
would look exactly the same as your first example, since you are pointing to
a file that is relative to the root of the website.
mappath("/_scripts/menu/mymenuscript.js").

So how do you solve this.
With ASP pages, I could detect where I'm running in the global.asa and set a APP variable and use that variable anywhere I'm building a path name. I
would have to modify all the HTML code etc <A
HREF='<%Application("BasePath")%>/myfolder/mywebpage.htm'>MyLink</A>
This is a pain...but doable. But that does not address a lot of the pure
HTML files or included script files in the ASP pages or Included ASP files..
Examples:
How would I change an ASP include file.
<!--#INCLUDE Virtual ="/Includes/MyAsp.asp" -->


To what? What is it that you want?

Peter Foti

Jul 19 '05 #2
I think he wants to put the same website on a different machine in a subweb.
So all of his absolute paths are wrong. He's looking for a "simple" way of
fixing ALL of them.

The only solution I can think of off hand, is to use a find and replace
tool.

Oh wait, if you set IIS to process html files as well, then you could use
the Application("BasePath") solution. But that won't solve the Includes
problem.
"Peter Foti" <pe****@systolicnetworks.com> wrote in message
news:vq************@corp.supernews.com...
"Stuart" <st***********@insurity.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi All,
I got a challenge to make the same APS/Script/Html run on different web
roots. I can not use relative pathing in a lot of cases. We use lots of included files so depending on where that file is running, the pathing in those included files varies. So we do a lot of absolute pathing.
Example: Instead of Mappath("../../../_scripts/menu/mymenuscript.js") we use
mappath("/_scripts/menu/mymenuscript.js").


Note, that is a relative path, NOT an absolute path. It is relative to

the root of the webserver (as specified by the leading /).
In one case, the code is loaded right on wwwroot with all the folders off
of
wwwroot.
So a path like so mappath("/_scripts/menu/mymenuscript.js") would return
c:\inetpub\wwwroot\_scripts\menu\mymenuscript.js

In another case, the SAME code has to run under a subweb, so we would
have to include the subweb name like so.
mappath("/MySubWeb/_scripts/menu/mymenuscript.js") would return
c:\inetpub\wwwroot\MySubWeb\_scripts\menu\mymenusc ript.js


I'm not sure what exactly it is you are asking for? Is there a file at

this location?
c:\inetpub\wwwroot\MySubWeb\_scripts\menu\mymenusc ript.js
If so, then you don't need to do anything. Your ASP looks correct.

Or do you want this to also point to:
c:\inetpub\wwwroot\_scripts\menu\mymenuscript.js

In that case, you must not include the sub folder name in the path. This
would look exactly the same as your first example, since you are pointing to a file that is relative to the root of the website.
mappath("/_scripts/menu/mymenuscript.js").

So how do you solve this.
With ASP pages, I could detect where I'm running in the global.asa and set
a
APP variable and use that variable anywhere I'm building a path name. I
would have to modify all the HTML code etc <A
HREF='<%Application("BasePath")%>/myfolder/mywebpage.htm'>MyLink</A>
This is a pain...but doable. But that does not address a lot of the

pure HTML files or included script files in the ASP pages or Included ASP

files..

Examples:
How would I change an ASP include file.
<!--#INCLUDE Virtual ="/Includes/MyAsp.asp" -->


To what? What is it that you want?

Peter Foti

Jul 19 '05 #3
Hi Peter,
Wrong choice of words, "Virtual Path" not Absolute path begin with "/".
A Relative path will navigate to a file based on where the current running
file is in the directory structure.
MapPath("../../FolderA/SomeFile.js") is a relative path.
MapPath("/FolderA/SomeFile.js") is a virtual path....read the MapPath() info
on IIS Help.

I thought my question was pretty clear...but I'll try again.
I want the "SAME" code base to be able to run on different websites with no
changes.
In one case the code will be running on the Web Root. In another case it
will be running under a SubWeb.
I don't want to have to change all the pathing information in the code base,
I want the code to be able to figure it out.
Does this help?

Thanks
Stuart

"Peter Foti" <pe****@systolicnetworks.com> wrote in message
news:vq************@corp.supernews.com...
"Stuart" <st***********@insurity.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi All,
I got a challenge to make the same APS/Script/Html run on different web
roots. I can not use relative pathing in a lot of cases. We use lots of included files so depending on where that file is running, the pathing in those included files varies. So we do a lot of absolute pathing.
Example: Instead of Mappath("../../../_scripts/menu/mymenuscript.js") we use
mappath("/_scripts/menu/mymenuscript.js").


Note, that is a relative path, NOT an absolute path. It is relative to

the root of the webserver (as specified by the leading /).
In one case, the code is loaded right on wwwroot with all the folders off
of
wwwroot.
So a path like so mappath("/_scripts/menu/mymenuscript.js") would return
c:\inetpub\wwwroot\_scripts\menu\mymenuscript.js

In another case, the SAME code has to run under a subweb, so we would
have to include the subweb name like so.
mappath("/MySubWeb/_scripts/menu/mymenuscript.js") would return
c:\inetpub\wwwroot\MySubWeb\_scripts\menu\mymenusc ript.js


I'm not sure what exactly it is you are asking for? Is there a file at

this location?
c:\inetpub\wwwroot\MySubWeb\_scripts\menu\mymenusc ript.js
If so, then you don't need to do anything. Your ASP looks correct.

Or do you want this to also point to:
c:\inetpub\wwwroot\_scripts\menu\mymenuscript.js

In that case, you must not include the sub folder name in the path. This
would look exactly the same as your first example, since you are pointing to a file that is relative to the root of the website.
mappath("/_scripts/menu/mymenuscript.js").

So how do you solve this.
With ASP pages, I could detect where I'm running in the global.asa and set
a
APP variable and use that variable anywhere I'm building a path name. I
would have to modify all the HTML code etc <A
HREF='<%Application("BasePath")%>/myfolder/mywebpage.htm'>MyLink</A>
This is a pain...but doable. But that does not address a lot of the

pure HTML files or included script files in the ASP pages or Included ASP

files..

Examples:
How would I change an ASP include file.
<!--#INCLUDE Virtual ="/Includes/MyAsp.asp" -->


To what? What is it that you want?

Peter Foti

Jul 19 '05 #4
"Stuart" <st***********@insurity.com> wrote in message
news:eu**************@TK2MSFTNGP09.phx.gbl...
Hi Peter,
Wrong choice of words, "Virtual Path" not Absolute path begin with "/".
A Relative path will navigate to a file based on where the current running
file is in the directory structure.
MapPath("../../FolderA/SomeFile.js") is a relative path.
MapPath("/FolderA/SomeFile.js") is a virtual path....read the MapPath() info on IIS Help.

I thought my question was pretty clear...but I'll try again.
I want the "SAME" code base to be able to run on different websites with no changes.
In one case the code will be running on the Web Root. In another case it
will be running under a SubWeb.
I don't want to have to change all the pathing information in the code base, I want the code to be able to figure it out.
Does this help?


Yes it does. This sounds like a problem that I had not too long ago. My
situation involved secure pages, where the unsecure version could be
accessed like this:
http://www.mysite.com/myfile.htm
and the secure version of the page could be accessed like this:
http://secure.myISP.com/mysite/myfile.htm

I had been declaring all of my includes, images, scripts, and style sheets
relative to the root, but then when I tried to access them securely, this
was a problem because now the path to those files was actually
"/mysite/myfiles" instead of "/myfiles".

Unfortunately, I was never able to get a solution for this problem. I
thought about doing what you mentioned (using some ASP variable in the
links, etc.), but that doesn't work for includes since they are processed
first. Ultimately, I decided that I didn't need to access my secure pages
over an unsecure connection, so I ended up with 2 methods. For non secure
pages, included files were relative to website root ("/"), and for secure
pages, included files were relative to the website root plus my subdirectory
("/mysite/"). You can probably still find the thread in
comp.infosystems.www.authoring.site-design.

I hope this helps (but I don't think there's a solution to your problem...
if there is, I'd love to see it posted here). :)

Regards,
Peter Foti
Jul 19 '05 #5
AFAIK the only foolproof way of achieving these ends is to use relative
paths. That way the paths will always be right as long as the folder/file
structure is consistent starting from YOUR root folder (i.e. the folder with
your default Home page for this application).

--
Cheers!
SiteGuru
http://www.siteguru.co.uk

"Peter Foti" <pe****@systolicnetworks.com> wrote in message
news:vq************@corp.supernews.com...
"Stuart" <st***********@insurity.com> wrote in message
news:eu**************@TK2MSFTNGP09.phx.gbl...
Hi Peter,
Wrong choice of words, "Virtual Path" not Absolute path begin with "/".
A Relative path will navigate to a file based on where the current running file is in the directory structure.
MapPath("../../FolderA/SomeFile.js") is a relative path.
MapPath("/FolderA/SomeFile.js") is a virtual path....read the MapPath() info
on IIS Help.

I thought my question was pretty clear...but I'll try again.
I want the "SAME" code base to be able to run on different websites with

no
changes.
In one case the code will be running on the Web Root. In another case it will be running under a SubWeb.
I don't want to have to change all the pathing information in the code

base,
I want the code to be able to figure it out.
Does this help?


Yes it does. This sounds like a problem that I had not too long ago. My
situation involved secure pages, where the unsecure version could be
accessed like this:
http://www.mysite.com/myfile.htm
and the secure version of the page could be accessed like this:
http://secure.myISP.com/mysite/myfile.htm

I had been declaring all of my includes, images, scripts, and style sheets
relative to the root, but then when I tried to access them securely, this
was a problem because now the path to those files was actually
"/mysite/myfiles" instead of "/myfiles".

Unfortunately, I was never able to get a solution for this problem. I
thought about doing what you mentioned (using some ASP variable in the
links, etc.), but that doesn't work for includes since they are processed
first. Ultimately, I decided that I didn't need to access my secure pages
over an unsecure connection, so I ended up with 2 methods. For non secure
pages, included files were relative to website root ("/"), and for secure
pages, included files were relative to the website root plus my

subdirectory ("/mysite/"). You can probably still find the thread in
comp.infosystems.www.authoring.site-design.

I hope this helps (but I don't think there's a solution to your problem...
if there is, I'd love to see it posted here). :)

Regards,
Peter Foti

Jul 19 '05 #6
"SiteGuru" <sa***@siteguru.co.uk> wrote in message
news:3f**********************@news.dial.pipex.com. ..
AFAIK the only foolproof way of achieving these ends is to use relative
paths. That way the paths will always be right as long as the folder/file
structure is consistent starting from YOUR root folder (i.e. the folder with your default Home page for this application).


Right, but the problem with that approach is that if I want to have some
base template for all of the pages in my site, then a file that was located
in:
/
could not use the same template as a file in:
/foo/
which could not use the same template as a file in:
/foo/bar/
etc.

And if I ever want to move a page from one level in the hierarchy to
another, I will need to modify that file to point to the new path relative
to the file. However, if I use a path relative to the root of the website,
then I don't need to modify any of those links.

Peter
Jul 19 '05 #7
On Wed, 5 Nov 2003 16:26:54 -0500, "Peter Foti"
<pe****@systolicnetworks.com> wrote:
"SiteGuru" <sa***@siteguru.co.uk> wrote in message
news:3f**********************@news.dial.pipex.com ...
AFAIK the only foolproof way of achieving these ends is to use relative
paths. That way the paths will always be right as long as the folder/file
structure is consistent starting from YOUR root folder (i.e. the folder

with
your default Home page for this application).


Right, but the problem with that approach is that if I want to have some
base template for all of the pages in my site, then a file that was located
in:
/
could not use the same template as a file in:
/foo/
which could not use the same template as a file in:
/foo/bar/
etc.

And if I ever want to move a page from one level in the hierarchy to
another, I will need to modify that file to point to the new path relative
to the file. However, if I use a path relative to the root of the website,
then I don't need to modify any of those links.


Welcome to the world of web organization. If you want the *same* code
to run on *all* sites they need the *same* structure.

You could work around this with a base URL, possibly as a variable in
the include statement. Maybe something like this(never tried, but ten
seconds would tell you if it works):

<% BaseURL="/foo/bar/" %>
<!--#Include File="<% =BaseURL %>folder1/folder2/filename.asp -->

Jeff
Jul 19 '05 #8
"Jeff Cochran" <jc*************@naplesgov.com> wrote in message
news:3f****************@msnews.microsoft.com...
You could work around this with a base URL, possibly as a variable in
the include statement. Maybe something like this(never tried, but ten
seconds would tell you if it works):

<% BaseURL="/foo/bar/" %>
<!--#Include File="<% =BaseURL %>folder1/folder2/filename.asp -->


No, that does not work because the include statement is processed before any
ASP gets processed.

Peter

Jul 19 '05 #9
"Jeff Cochran" <jc*************@naplesgov.com> wrote in message
news:3f****************@msnews.microsoft.com...
You could work around this with a base URL, possibly as a variable in
the include statement. Maybe something like this(never tried, but ten
seconds would tell you if it works):

<% BaseURL="/foo/bar/" %>
<!--#Include File="<% =BaseURL %>folder1/folder2/filename.asp -->


Interestingly enough, I think I have found the solution to this problem:
http://www.aspfaq.com/show.asp?id=2042

Peter
Jul 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Vincent | last post by:
First, here is a page to help you figure out what I'm talking about: http://relinquiere.free.fr/test.html As you can see in the source of this page, the structure is the following : - a banner...
0
by: clintonG | last post by:
I've used plenty of ../../css/styles.css pathing but some hosting providers disable pathing. I also use ~/css/styles.css when needing to provide access to the css directory when it is in the root...
8
by: Frank Buss | last post by:
A new challenge: http://www.frank-buss.de/marsrescue/index.html Have fun! Now you can win real prices. -- Frank Buß, fb@frank-buss.de http://www.frank-buss.de, http://www.it4-systems.de
0
by: Richard Jones | last post by:
The date for the second PyWeek challenge has been set: Sunday 26th March to Sunday 2nd April (00:00UTC to 00:00UTC). The PyWeek challenge invites entrants to write a game in one week from...
0
by: richard | last post by:
The date for the second PyWeek challenge has been set: Sunday 26th March to Sunday 2nd April (00:00UTC to 00:00UTC). The PyWeek challenge invites entrants to write a game in one week from...
2
by: nino9stars | last post by:
Hello, I have just started messing with absolute positioning on webpages, and it definitely let's you do some creative things. Well, after much searching and help, I got the images I was using...
3
by: Thierry | last post by:
For those interested in <b>programming riddles</b>, I would like to announce a new programming challenge I'm just launching at http://software.challenge.googlepages.com This challenge is in its...
0
by: Richard Jones | last post by:
The fifth PyWeek is only a month away. Come along and join the fun: write a video game in a week! There's some really interesting new libraries that have popped up recently. Have a gander on the...
13
by: lawpoop | last post by:
Hello all - I have a two part question. First of all, I have a website under /home/user/www/. The index.php and all the other website pages are under /home/user/www/. For functions that are...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.