sdlangers Posted April 22, 2005 Posted April 22, 2005 Hi, this is longwinded, but straightforward... please take a look... I'm trying to set up a website that will eventually be on its own url, but for now it is in development on my test machine. i want to include a file like this: <!-- #Include Virtual="/includes/header.inc"--> so when i'm finished, my real website would have this url to the include file: http://www.mywebsite.com/includes/header.inc but here's the problem - right now its in a local virtual directory at: d:\inetpub\wwwroot\mywebsite\includes\header.inc and the virtual directory is set up in IIS to point to mywebsite, so i can view it at: http://localhost/mywebsite/index.aspx however, it cant find the include file - it gives the error message as: Parser Error Message: Could not find a part of the path "d:\inetpub\wwwroot\includes\Header.inc". so it is skipping the virtual directory's folder. how do you make it start in the virtual directory so that the link will work the same as it does if you had it on a live site???? thanks for your help Quote
mark007 Posted April 22, 2005 Posted April 22, 2005 I think you just want to remove the first slash which makes it start from the web root. :) Quote Please check the Knowledge Base before you post. "Computers are useless. They can only give you answers." - Pablo Picasso The Code Net
sdlangers Posted April 22, 2005 Author Posted April 22, 2005 sorry - thats a bad example that i gave you. i need it to work from any directory or sub-directory if i removed the first / then it would work only for the root directory, so, yes the index.aspx page above would work but i want to use that same include statement in my sub-directories and the idea of the first / is to make it start from the root of the site. it works fine as a regular website on the live version... i.e. when i dont have it as a virtual directory... but it wont work as a virtual directory off my localhost site for example: it works for http://www.mywebsite.com/subfolder/somepage.aspx but it doesnt work for the same page on my dev machine at: http://localhost/mywebsite/subfolder/somepage.aspx and its the exact same code on both - so i guess its something that i have to change with the virtual directory in IIS any ideas? Quote
PWNettle Posted April 23, 2005 Posted April 23, 2005 (edited) If you're happy with how it's working on the "live" site then you probably should alter how your development environment is behaving so that it mimics your live environment. Change the physical location of your IIS root mapping to be your project's physical root folder. Right now your dev IIS virtual root is (most likely) mapped to: c:\inetpub\wwwroot Change it to: c:\inetpub\wwwroot\yourproject ...if your physical files are actually off of wwwroot, otherwise change it to whatever path contains your project files (IIS doesn't care what its root is mapped to - I change my root mapping so much for different code bases that I created a task bar tool to do it so I don't have to use the clunky management console). One you've changed the IIS virtual root to point directly to your project you can get to your project as "http://localhost" and all your root relative URLs will work properly. Paul PS - One extra word - if you haven't messed with changing your root when doing ASP.Net _and_ if you use ASP.Net validators then you'll want to make a virtual mapping for the aspnet_client folder that physically exists under c:\inetpub\wwwroot. Once you've made this mapping once it'll persist whenever you change the root around. ASP.Net's validator javascript is in that folder so validators won't work if it's not available. Edited April 23, 2005 by PWNettle Quote
sdlangers Posted April 23, 2005 Author Posted April 23, 2005 thanks paul i had thought of doing that briefly, but 2 things came to mind 1. security concerns, since i'd have to enable scripts on my main wwwroot directory (maybe this is nothing to be concerned about, but i noticed they were disabled by default) 2. what if you were a developer that had a few websites under development on a dev server - surely there is a way of having them all up and running at the same time without having to switch between them? in any case, what you said works good - so thank you.. this reply is just for discussion if anyone is interested thanks Quote
PWNettle Posted April 23, 2005 Posted April 23, 2005 Another option might be to create a virtual mapping to only your "includes" folder off the root - that way any project you create could link to it with "/includes/..." regardless of where it was in the virtual heirarchy. 2. what if you were a developer that had a few websites under development on a dev server - surely there is a way of having them all up and running at the same time without having to switch between them? A server can host multiple sites, for sure, but that doesn't mean that you as a developer will run a development environment that works the same way (and hopefully you develop seperate from your live sites!) It might depend on what operating system you have, what web server you have, and what your network will let you get away with. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.