Including the same ASP file across several websites all hosted on the same server?
April 19, 2006 12:36 PM   Subscribe

ASP include files. Is there a way of including the same ASP file across several websites all hosted on the same server?

I know this isn't experts exchange, but I know there's some very knowledgeable techies here :)

Basically, I have a functions.asp file which contains several useful functions (such as one that formats the date nicely).

Say I have 10 websites hosted on one Windows2003 server that all have their own copies of functions.asp. I want just one copy of functions.asp that resides in its own directory, even outside the wwwroot, that i want to reference, so every time i change one i don't have to change all of them.

Possible?

< !--#include file="d:\include\functions.asp" -->

doesn't work!

Thanks.
posted by derbs to Computers & Internet (5 answers total)
 
Best answer: Here's what you do--put the file in a centralized directory, then make that directory a "virtual directory" on every site using IIS Admin. Then you can include the file from other pages.
posted by vraxoin at 12:55 PM on April 19, 2006


Derbs, "Classic ASP" doesn't have a build in include() or require() function that will do what you want. There is a work around, but it's a bit of a hack. What you do is

1. Read the contents of your ASP file into a string variable using the file system object

2. Pass that string to the execute (or is that eval?) function

Disclaimer: I am years and years removed from this.
posted by alana at 1:09 PM on April 19, 2006


Response by poster: ah ha i think you have it vraxoin!

Would i have to use include virtual= instead of include file= then?

Thanks!
posted by derbs at 2:43 PM on April 19, 2006


Yes, vraxoin has it and you do need to use #include virtual and the path should start with a ~
posted by yerfatma at 4:20 PM on April 19, 2006


You'll also want to make sure the include virtual directory doesn't have read access turned on, assuming you don't want users accessing your include files directly.
posted by Bezbozhnik at 4:51 PM on April 19, 2006


« Older Free poly-sized pixel fonts?   |   How to get a job sea kayaking? Newer »
This thread is closed to new comments.