April 23rd, 2005, 10:10 AM
How to configure website to use INCLUDE VIRTUAL
I maintain a client's website which is hosted by another company. The website is written in ASP. I develop changes to the website locally on my Windows XP Pro computer running IIS 5.1.
There are a few places in the app where server side include files are used. Unfortunately, I have to use INCLUDE VIRTUAL for the production site and INCLUDE FILE when developing locally. Here are the two versions:
This means I have to remember to change the server side include statements before I upload changes to these files.
<!-- I use the following in DEV -->
<!-- #INCLUDE FILE="../include/ObjDef.inc" -->
<!-- I use the following in PROD -->
<!-- #INCLUDE VIRTUAL="/include/ObjDef.inc" -->
Can anyone tell me how I can configure my local machine to work with the INCLUDE VIRTUAL directive?
I saw a separate post that said "IIS wont let you call "Includes virtual" from any virtual directory that is not on the root." I have checked IIS and the path for my local copy of the website is listed as c:\inetpub\wwwroot\MySite. Is this incorrect?
Thank you in advance.
April 23rd, 2005, 05:43 PM
Is "MySite" listed as an Application in IIS? If so, then include virtual will work because it has its own application scope and root.
April 26th, 2005, 10:35 AM
In IIS, MySite properties list "MySite" as the Application Name with a starting point of
Is this correct? Should I try removing and adding back the application name?
<Default Web Site>\MySite
By the way, the error information I get is as follows:
Active Server Pages, ASP 0126 (0x80004005)
The include file '/include/ObjDef.inc' was not found.
/mywebsite/admin/mypage.asp, line 24
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)
April 26th, 2005, 11:56 PM
If you're using a workstation version of windows (XP or whatever) you are restricted to a single website, so if you're using the box for development you can't duplicate the web structure of your target server. Each of your development websites will probably be virtual directories under your root web and when you transfer to the web server you'll probably run across many broken links and includes.
Easiest would be to use a server OS for development.
I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain
You are correct; I am using XP Pro and my dev sites are all virtual directories under the root.
Since I only need to work with one web site at a time, is there any way to configure things so that the #Include virtual statement will work for a single dev site? For example, can I point the default web site's home directory (normally, c:\inetpub\wwwroot) to my dev site (say, c:\inetpub\wwwroot\MyDevSite)?
What are the consequences of such action?
Thank you in advance.
Include virtual will always go from the root web of the website, so unfortunately you must specify the additional virtual directory in the include virtual url.
There is no simple workaround I know, other than use a server OS that supports multiple websites.
Just a suggestion, why don't you just use INCLUDE FILE on your server? As long as all the directories are the same, it would work the same. Unless your host doesn't allow INCLUDE FILE for some odd reason(I'm not that good with this stuff, but I know enough for the likes of me )
It really doesn't matter if you use include file or include virtual if you're working on a non-server IIS that only allows a single website. You still have to deal with that pesky virtual directory folder (unless you put your includes outside the web and your host allows parent paths).
When I've used Include File on the hosted production site, it doesn't work.
I am able to use Include Virtual on my dev server (XP Pro with IIS 5.1) as long as I set the default web site's home directory (normally, c:\inetpub\wwwroot) to my dev site (say, c:\inetpub\wwwroot\MyDevSite). This allows me to make a simple config change to my local IIS instead of changing all the source files that have the errant include statements.
Thanks for everyone's suggestions.