Many administrators migrating from IIS6 to IIS7 face this common scenario: you've accidentally created an Application when you really needed a Virtual Directory. Unlike IIS6 where this conversion was straightforward, IIS7's management interface doesn't provide a direct "Convert to Virtual Directory" option.
The most efficient method uses PowerShell with the WebAdministration module:
Import-Module WebAdministration $appPath = "IIS:\Sites\Default Web Site\YourApp" $vdirPath = "IIS:\Sites\Default Web Site\YourVDir" Rename-Item $appPath $vdirPath Set-ItemProperty $vdirPath -Name applicationPool -Value $null
For those preferring command-line tools:
appcmd set app "Default Web Site/YourApp" /applicationPool: appcmd set vdir "Default Web Site/YourVDir" /physicalPath:"C:\YourPath"
After conversion, verify these settings:
- Ensure the converted item appears under "Virtual Directories" not "Applications"
- Check that no application pool is assigned
- Verify the physical path remains correct
For GUI users:
- Open IIS Manager
- Navigate to your application
- Right-click → "Manage Application" → "Advanced Settings"
- Clear the Application Pool field
- Click OK to save changes
Watch out for these issues:
- Inherited web.config settings from parent applications
- Permission changes needed for the new virtual directory
- Potential breaking changes in relative paths
Many developers migrating from IIS6 to IIS7 face this common scenario: you've accidentally created an application when you meant to create a virtual directory, and now need to revert it without losing configurations. Unlike IIS6 where this was straightforward, IIS7's hierarchical configuration system makes it less obvious.
In IIS7+, applications and virtual directories are fundamentally different objects in the configuration schema. An application creates a new application boundary (with its own app pool, configuration, etc.), while a virtual directory simply points to alternative content.
// Configuration difference in applicationHost.config
Here's how to transform an application back to virtual directory using IIS Manager:
- Open IIS Manager and navigate to your site
- Right-click the application and select "Remove" (not Delete!)
- Immediately right-click the parent node and select "Add Virtual Directory"
- Use the same alias and physical path as the original application
For server administrators handling multiple conversions:
Import-Module WebAdministration $sitePath = "IIS:\Sites\Default Web Site" $appName = "ProblemApp" # Remove application but keep content Remove-WebApplication -Site "Default Web Site" -Name $appName # Create virtual directory in same location New-WebVirtualDirectory -Site "Default Web Site" -Name $appName -PhysicalPath "C:\inetpub\wwwroot\$appName"
Before converting, ensure you:
- Note any custom authentication settings
- Record special authorization rules
- Save unique request filtering values
- Back up web.config if it exists in the application root
Error: "The directory specified is invalid"
Solution: Verify the physical path exists and IIS_IUSRS has read access
Error: Configuration inheritance problems
Solution: Use appcmd to clear location tags:
appcmd clear config "Default Web Site/ProblemApp" -section:system.webServer/security/access