Virtual directories and application root

L

Leszek

Hello,

Could anybody explain what's a difference between a virtual directory and an
application root under IIS? I'm a little bit confused.

This is mu problem:

Let's assume the following directory structure:

FileManager (application name a.k.a. virtual directory?)
Images
header.gif
Styles
styles.css
Scripts
start.aspx

The start.aspx script utilizes the images and styles in the following way:
<link rel="stylesheet" href="/FileManager/Styles/styles.css"
type="text/css">
<img src="/FileManager/Images/header.gif">

That's fine when the name of the virtual directory is "FileManager", but it
might be different. I do not know the name when I design start.aspx. I would
prefer to use something like this:
<link rel="stylesheet" href="/Styles/styles.css" type="text/css">
<img src="/Images/header.gif">

I can use this syntax on Unix (/ means "start from the root directory" - I
do not need to provide the directory name), but it seems IIS requires the
application name.
Am I doing something wrong? Is there any solution for this issue?

Thanks,
Leszek Taratuta
 
A

Alex Papadimoulis

Hello Lszek,

A virtual directory is a "pointer" to a physical directory. Example, files
on www.MySite.com are not actually stored there, more likely, they are
stored in c:\inetpub\wwwroot\mysitecom\ . The rootlevel wil allways be a
virtual directory (MySite.com/). You can add other virtual roots, example,
"MySite.com/Images" could point to "c:\documents\alex\pictures\". These VDs
are set up in IIS.

An application root is a type of virtual directory that isolates the
Sessions and Configuration for everything in the folder it's in. By
default, the RootLevel (Mysite.com/) will be an application root. You can,
however, define other applications. For example, if you had the application
MySite/Application1, and also had MySite/Application2, users logged into the
former would not be logged into the latter. they aplications are isolated
from eachother.

I hope this clears things up. Just reply if you have more questions.

Alex Papadimoulis
 
L

Leszek

Thanks a lot. Now I understand the difference between a virtual directory
and an application root.
Although I still do not know how to be independent from the application
name. I would like to use URLs like this:
/images/myimage.gif
instead of
/myapp/images/myimage.gif
("myapp" is the application root)

Should I define another virtual directory on the images folder? What about
other folders I would like to treat the same way?
Let's say I have the following folders:
c:\inetpub\wwwroot\myapp\images
c:\inetpub\wwwroot\myapp\catalogimages
c:\inetpub\wwwroot\myapp\styles
c:\inetpub\wwwroot\myapp\controls
c:\inetpub\wwwroot\myapp\examples
etc.

My application root is defined on c:\inetpub\wwwroot\myapp.
I would like to use "\images", "\catalogimages", "\styles", etc instead of
"\myapp\images", "\myapp\catalogimages", "\myapp\styles" with as little
hassle as possible?

Thanks for any advice,
Leszek Taratuta
 
A

Alex Papadimoulis

Hi Leszek,

It is certainly possible, but it depends on your development enviornment.
If you develop on a 2000/XP Pro box, then you are allowed only one "site"
(i.e., root level), which is why you have to use a subdirectory
(localhost/myapp). This leaves you with a few options:
1. Develop on your machine using all relative URLs (instead of
"/myapp/images/image.gif", use "../images/image.gif", or whatever), and
deploy the application to the server's root URL
2. Get a development server, and develop directly on the server, instead of
the local machine.
3. Change your OS to a server OS, so you can be allowed different sites

If you go with #2 or #3, you'll want to set up different sites in IIS.

I use #2, and have a whole subnet dedicated to development sites (i.e.,
192.168.100.xxx are development sites). One issue you'll probably run into
if you go with #2 is debugging on the server. I was never able to get it to
work, so I dont even bother, but then again, I found using VS.net to develop
websites just too much of a PITA.
Codebehind, horrible HTML handling, bad code generation, oooh I could go
on --- Whidbey's looking promising, but for now, it's Dreamweaver for me.
(Dont get me wrong tho, VS.net is essneital to create middle tier, it just
rellly fails on the web site).

Alex Papadimoulis
 
L

Leszek

Thanks a lot.

For now I will stick to the first option (relative URLs).
I am also going to try developing directly on the server instead of my local
machine. You are right there are some debugging issues, but I hope I will
resolve them.
In the future it is a good idea to have a server locally.

IMHO
VS.NET is not bad. I'm using Dreamweaver just for visual desing. For
coding - VS.NET.

Thanks again for your help,
Leszek Taratuta
 
J

Joerg Jooss

Leszek said:
Thanks a lot. Now I understand the difference between a virtual
directory and an application root.
Although I still do not know how to be independent from the
application name. I would like to use URLs like this:
/images/myimage.gif
instead of
/myapp/images/myimage.gif
("myapp" is the application root)

You can use ~/images/myimage.gif
"~" references the web app's root directory.

Cheers,
 

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,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top