include file outside web site

S

SteveT

Is it possible to have an include file that resides outside of the web site
parent folder?
For instance, lets say you have several websites under
Inetpub/global/websites/ but the include file is in Inetpub/inc/
I get a file not found error trying file/virtual starting with the root and
even using C:/Inetpub.

Example

Inetpub/global/websites/website1/global.asa

Inside global.asa is the statement

<--Include file="C:/inetpub/inc/functions.inc"-->

Thanks,
Steve
 
T

Trevor L.

SteveT said:
Is it possible to have an include file that resides outside of the
web site parent folder?
For instance, lets say you have several websites under
Inetpub/global/websites/ but the include file is in Inetpub/inc/
I get a file not found error trying file/virtual starting with the
root and even using C:/Inetpub.

Example

Inetpub/global/websites/website1/global.asa

Inside global.asa is the statement

<--Include file="C:/inetpub/inc/functions.inc"-->

Thanks,
Steve

Yes, I think so

I have this in my site (see signature)
<!--#include file="_fpclass/guestbook.inc"-->
It is called from guestbook.asp in the parent folder

I assume that you can also navigate up and down the folder structure using
(for example) ../foldername/filename.inc

From Inetpub/global/websites/website1/global.asa, you would have to go up
three (to Inetpub/) then down to inc/.

So I would try:
<!--#include file="../../../inc/functions.inc"-->

--
Cheers,
Trevor L.
[ Microsoft MVP - FrontPage ]
MVPS Website: http://trevorl.mvps.org/
----------------------------------------
 
S

SteveT

Thanks for the responses but my problem is that I want to use this as a
generic file but some of the web site folders are at different levels.
So I would have to adjust each global.asa that references the include file
depending on what level the global.asa file is.

I need to refer to it from the root somehow.
When I use <-- include file="C:/inetpub/inc/functions.inc"--> I get file not
found.
Interesting enough ado, filesystem and other objects work fine referring to
the logical path but asp does not seem to for some reason.

Parent paths are enabled.

Thanks,
Steve
 
M

Mike Brind

SteveT said:
Thanks for the responses but my problem is that I want to use this as a
generic file but some of the web site folders are at different levels.
So I would have to adjust each global.asa that references the include file
depending on what level the global.asa file is.

I need to refer to it from the root somehow.
When I use <-- include file="C:/inetpub/inc/functions.inc"--> I get file
not
found.
Interesting enough ado, filesystem and other objects work fine referring
to
the logical path but asp does not seem to for some reason.

Parent paths are enabled.

<!--#include file--> makes implicit use of Server.Mappath to do its magic.
Server.Mappath maps a virtual or relative file path. <% Response.Write
Server.Mappath("C:/inetpub/inc/functions.inc") %> will probably give you
something like this:

C:/InetPub/wwwroot/test/C:/inetpub/inc/functions.inc

- assuming that you are running this script in the "test" directory.
 
A

Anthony Jones

SteveT said:
Is it possible to have an include file that resides outside of the web site
parent folder?
For instance, lets say you have several websites under
Inetpub/global/websites/ but the include file is in Inetpub/inc/
I get a file not found error trying file/virtual starting with the root and
even using C:/Inetpub.

Example

Inetpub/global/websites/website1/global.asa

Inside global.asa is the statement

<--Include file="C:/inetpub/inc/functions.inc"-->

Thanks,
Steve


The file attribute of an #include directive can only be a relative path and
enabling parent paths is a security risk.

The solution to this problem is to add virtual folder to the root of each
website that points to the inc folder. (BTW, it's also not a good idea to
use the .inc extension .asp is better)

You then change your include directives on all your pages to:-

<!-- #include virtual="/inc/functions.asp" -->

Anthony.
 
S

SteveT

I don't believe you can use <% %> in the global.asa. I have not found a away
to concatenate the file for the include statement.

Thanks,
Steve
 
S

SteveT

Thanks for all of the responses.

It's interesting because Parent Paths is selected by default. Also, ado,
filesystem and other objects allow logical paths so I am not sure what MS
was thinking for security issues.

Is there a way to setup a global virtual folder for all web sites? It
appears I have to add it to each one individually.

Thanks,
Steve
 
M

Mike Brind

No you can't. I wasn't referring to your desire to use Global.asa. I was
talking generally.

Mike

SteveT said:
I don't believe you can use <% %> in the global.asa. I have not found a
away
to concatenate the file for the include statement.

Thanks,
Steve
 
S

SteveT

A

Anthony Jones

SteveT said:
Thanks for all of the responses.

It's interesting because Parent Paths is selected by default. Also, ado,
filesystem and other objects allow logical paths so I am not sure what MS
was thinking for security issues.

Is there a way to setup a global virtual folder for all web sites? It
appears I have to add it to each one individually.

It's not possible to create a 'global' virtual folder that appears in all
websites. How many sites do you have? We are talking sites not just
applications right?
 
A

Anthony Jones

Dave Anderson said:
That's only true if you don't tell IIS to parse .inc files with asp.dll, a
step that makes the two extensions equals.

Making an unnecessary change to a servers default configuration is not a
good idea. If you lose the server it's just another tweak you need to
remember to do to when recreating your app.

It's not just though. Most editors I've come across do not recognise .inc as
typically holding ASPs mix of VBScript and HTML syntax. Some will allow you
to specify the .inc as such but that's another tweak you need to do.

Overall it's just a lot less hassle using .asp as the extension and
forgetting about it.
 
S

SteveT

Right now there are about 10 sites with more to come.
I reorganized my folder structure and using the relative path for now.

Thanks for all of the responses,
Steve
 
S

SteveT

Yeah, I think we are all getting away from .inc. It was more for
example/clarification.
It is true that editors like Homesite will highlight key words if the file
is .asp which helps coding.

Steve
 
A

Anthony Jones

Dave Anderson said:
I flatly reject that assertion. A custom 404 error page is the simplest
counterexample.

In that case your change to the custom errors property would not constitute
an 'unneccessary' change now would it?
Besides, you still have not demonstrated that it is unnecessary.
You don't know how many .inc files he "needs" to convert to the .asp extension. Nor do
you know if he has to babysit vendor-provided applications that could use
such an extension. Heaven knows my company has purchased its share of
"solutions" at various points in the past.

My original comment to the OP on the matter was enclosed in parentheses and
prefixed with BTW. I was pointing out that in general .asp is better the
..inc

It was to this point alone you responded:-

Were you making a general comment here or one specific to the OP's case?
That's what they pay us for. Get used to it.

There are other people on my team who have that responsibility. I try not
to make their life harder by asking them to make changes that aren't really
necessary. We all get paid by customers to help their business make
progress not to fiddle around with servers.

I agree that IDE eye candy

That term 'candy' demigrates the importance of syntax highlighting.
However, silly but time consuming bugs can be avoided when the such tools
help to highlight them.
(and intellisense) are great reasons to use the
.asp extensions -- although they do little for people like me, since none I
have encountered can be configured to treat include .asp files as
JScript --

Yeah I can see that being annoying.
but that certainly does not make the use of .inc a bad idea.

On it's own probably not.
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top