Mastering IIS FTP Part 2: Virtual Directories and Physical Directories
page 1 of 1
Published: 16 Aug 2004
Unedited - Community Contributed
Abstract
If you've ever tried to use FTP to access virtual directories in IIS, you've likely been frustrated to see them not show up. This article shows you how to overcome that problem.
by Web Team at ORCS Web
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 20867/ 30

In Part 1 we covered ways to use the hidden power of Microsoft's FTP server product. We talked about ways to leverage virtual directories along with Windows user accounts.

Today I want to take this one step further and discuss how to work with the IIS FTP quirks with using virtual directories as . . . yes, virtual directories. Because Microsoft has this unique way of utilizing virtual directories to offer more control, it also means that simply using virtual directories for their original purpose isn't as obvious as it should be.

Rule #3: A virtual directory created in IIS FTP isn't seen by an FTP program.

If we want to create a virtual folder that points to a different location on a server, one of the first things we will notice is that if we create the virtual directory in IIS FTP and then use a FTP client to log in, we won't see the folder!! We can use ChgDir if our FTP client supports it and type in the name of the vdir, but that's often times not good enough. We want to actually see it.

Let me explain it further. Consider the following folder structure where d:\domains\mysite\ is the FTP root path:

d:\domains\mysite\
d:\domains\mysite\images\
d:\domains\mysite\bin\
d:\domains\mysite\admin\

Now, let's create a virtual directory in IIS FTP called downloads which will point to: e:\downloads\

When we log into our FTP account, we will see images, bin and admin but we won't see downloads.

Why is that? Since virtual directories aren't always used for their original purpose, as we saw in Part 1, they don't automatically appear. The other reason is that FTP programs will scan the files and folders on disk to determine what to display. Since virtual directories don't reside at the folder level, they won't be shown with the rest of the folders.

So what do we do? Fortunately the solution is simple.

Tip #2: Create an empty “physical” directory to have a “virtual” directory appear in a FTP program.

Since the FTP client program will check for files and folders on disk, simply create an empty folder on disk where the virtual directory should show up. In my example above, it means creating an empty folder called d:\domains\mysite\downloads\. Now, after you log into this FTP account with your FTP program, you will see images, bin, admin, and downloads. If you double click on downloads you will be taken to e:\downloads because the virtual directory in IIS FTP will take precedence.

Rule #4: If both a virtual directory and physical directory exist, the virtual directory takes precedence.

In my example above, I've created a “virtual“ folder which redirects to another location on the server, and a “physical“ folder so that it will show up in my FTP program. Even if I put files in the empty downloads folder, I won't be able to access them by double clicking on the downloads folder. Instead of being directed to d:\domains\mysite\downloads\ (physical folder), I will be directed to e:\downloads\ (virtual folder).

In summary, when creating a virtual directory that should show up in the FTP client program, make sure to create an empty physical directory to match.

In Part 1 we covered working with virtual directories and Windows users. In this part we covered working with virtual directories and physical directories. In Part 3 and Part 4 we will cover IIS6 user isolation, why I don't use it, and some tricks for more advanced configurations.

by Scott Forsyth, Director of IT at ORCS Web, Inc. - a company that provides managed hosting services for clients who develop and deploy their applications on Microsoft Windows platforms.



User Comments

Title: Confusing but this cleared it up   
Name: ms. dos
Date: 2010-10-22 12:31:00 AM
Comment:
The issue I had was that the vdir has to be created in the ftp root. Since I am using user isolation with AD I was confused on where to create the vdir in iis for the user to be able to see it. So make sure permission are correct, create your vdir in the ftp root, create your placeholder dir in the user directory and away you go.
Title: Didnt Work Here Either   
Name: Me
Date: 2010-02-07 9:31:49 PM
Comment:
Didnt work for me either. The folders are clearly there and I can access them if I use the change directory feature but they do not show up in the list. I have full permissions on this user and have tried both MS-DOS and Unix folder structures. Should've known Windows' built in FTP would be garbage.
Title: Works from the browser, not FTP client   
Name: Michael B
Date: 2009-11-05 11:23:29 AM
Comment:
I tried adding a physical directory with the same name. It still works from the browser (it did before I did that) but FTP client (command window nor WS_FTP) see only the physical directory, not the virtual directory of the same name. The directory which the vdir points has the same file permissions as the rest of the web site directories.

Thoughts?

Thanx...
Title: start   
Name: startd
Date: 2007-06-06 1:51:26 PM
Comment:
I have permission errors when users upload large amounts of info. For example if a use uploads 3 html files or documents they have no problems, but if they upload a folder of pictures or an entire website, they get a permission error. Thoughts as to why this would happen only for large uploads. Please email the response
Title: Briljant   
Name: Wessel van Sandwijk
Date: 2006-10-27 4:42:17 AM
Comment:
This is a great article.
Did it, done it, and it works.
Thanks a lot.
The virtual directories show up in the ftp client.
It's nasty way to let the virtual directories show up, but it works..

Thanks.
Title: Re: doesn't work for me :(   
Name: Scott Forsyth
Date: 2005-11-04 9:22:38 AM
Comment:
Hi Veronica,

What type of issue are you running into? Permission issues are common. The user will need at least "List" access to the root of the ftp site as well as the vdir that you have set up. Event viewer often gives good clues too. If it turns out to be a difficult issue, use filemon from www.sysinternal.com. It's free, fast and ok to run on a production server and will tell you exactly which user is denied which permission to which file or folder.
Title: doesn't work for me :(   
Name: Veronica
Date: 2005-11-03 7:54:57 PM
Comment:
wonderful article.

I did try making an empty physical directory to match the virtual directory but no go. Any clues?
Title: Fantastic!   
Name: Mary
Date: 2005-05-13 2:28:01 PM
Comment:
Thanks a bunch...wasn't sure how to get the virtual directory to show up in the folder list. Worked like a charm!

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2017 ASPAlliance.com  |  Page Processed at 2017-08-20 9:38:00 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search