Creating a virtual directory
A website in IIS maps to a directory on the computer. If there are subdirectories within that folder, they'll show up in the IIS manager too. For example, the following website has the Scripts
and CSS
folders inside its root folder:
If we right-click on MyWebsite and choose Explore, we'll see that the Scripts
and CSS
directories sit squarely within the folder that the site is mapped to:
What if we wanted to map to a directory that wasn't within the root folder of the website? Maybe it's a folder at C:\Photos
. To do this, we'll need to create a virtual directory. A virtual directory simply maps to some place outside the normal website folder. In this recipe, we will add a Photos
directory to the C:
drive and map it as a virtual directory in IIS.
Getting ready
To prepare for this recipe, perform the following steps:
Create a new setup project and name it
VirtualDirectoryInstaller
.Add
IIsExtension
to the project by right-clicking on the References node in Solution Explorer...