On Windows Server 2022, create the virtual directory in IIS Manager → Sites → your website → View Virtual Directories → Add Virtual Directory, replacing the legacy New → Virtual Directory wizard shown in the image.
Create the virtual directory
- Sign in to the web server with an administrator account.
- Open Server Manager → Tools → Internet Information Services (IIS) Manager.
- If IIS Manager is unavailable, install the Web Server (IIS) server role first.
- In the Connections pane, expand:
- Your server
- Sites
- The target website, such as Default Web Site
- Select the website or the application under which the directory should appear.
- In the Actions pane, select View Virtual Directories.
- Select Add Virtual Directory...
- Enter:
- Alias: the URL segment, such as
Sales
- Physical path: either:
- Local folder:
D:\WebContent\Sales
- Remote SMB share:
\\FileServer\Share\Sales
- For a remote share, select Connect as... and enter an account that can access the share.
- Select Test Settings.... Both Authentication and Authorization should succeed.
- Select OK to create the directory.
These are the current IIS Manager steps; the virtual-directory configuration used by IIS 10 was not changed from earlier IIS versions.^1^
On the file server hosting \\FileServer\Share\Sales:
- Share the folder.
- Grant the account configured through Connect as... the necessary share permissions.
- Grant the same account the necessary NTFS permissions on the folder:
- Read and execute for read-only web content.
- Additional modification permissions only if the application must write there.
- Use an account with only the permissions required for the content.
A remote virtual directory requires both appropriate sharing permissions and NTFS permissions.^2^
Avoid placing a clear-text password directly in ApplicationHost.config; IIS Manager encrypts the password when it writes the configuration.^1^
Test it
Browse to:
http://WebServer/Sales
Replace WebServer with the server name and Sales with the alias. The content from the mapped local folder or UNC share should be returned. The virtual directory inherits configuration and security settings from its parent website.^2^
If Test Settings reports an authorization failure, correct the remote folder’s share/NTFS permissions or the Connect as... credentials before changing IIS authentication settings.
References
- Virtual Directory <virtualDirectory>
- How to create a virtual directory on an existing Web site to a folder that resides on a remote computer