Virtual Directories in IIS
Virtual Directories in IIS
A virtual directory maps an alias in the URL space to a physical directory on disk (or a network share). Virtual directories let you organize web content without matching the physical folder structure.
Creating a Virtual Directory
- Open Internet Services Manager.
- Expand the target web site.
- Right-click the site → New → Virtual Directory.
- Enter an alias (e.g.,
docs). This becomes the URL path:http://server/docs/. - Browse to the physical path (e.g.,
D:\Documentation). - Set permissions: Read, Run scripts (ASP), Execute (CGI/ISAPI), Write, Browse.
- Click Finish.
Virtual Directory vs. Application
A virtual directory becomes an application when it runs in its own application space. Applications have their own Session and Application objects in ASP.
To create an application from a virtual directory:
- Right-click the virtual directory → Properties.
- Under Application Settings, click Create.
- Choose the application protection level:
- Low (IIS Process): Runs in
inetinfo.exe— fastest but a crash takes down IIS. - Medium (Pooled): Runs in a shared
dllhost.exepool — default and recommended. - High (Isolated): Runs in its own
dllhost.exe— most stable but uses more memory.
- Low (IIS Process): Runs in
Mapping to a UNC Path
To map a virtual directory to a network share, enter the UNC path (\fileserver\share\docs) and provide credentials with read access. IIS uses these credentials to access the remote content.
Scripting with ADSI
' Create a virtual directory programmatically using ADSI
Set objWeb = GetObject("IIS://localhost/W3SVC/1/Root")
Set objVDir = objWeb.Create("IIsWebVirtualDir", "docs")
objVDir.Path = "D:\Documentation"
objVDir.AccessRead = True
objVDir.AccessScript = True
objVDir.SetInfo
WScript.Echo "Virtual directory /docs created."