Search code examples
c#iisiis-7virtual-directory

create a virtual directory for a website programmatically- web application


I would like to know if it possible to create a virtual directory in C# directly to a site instead of creating a web application and then linking a virtual directory to that. I am using iis 7. thanks ! Src:http://blogs.msdn.com/b/carlosag/archive/2006/04/17/microsoftwebadministration.aspx


Solution

  • You can do this in PowerShell.

    From Learn IIS

    PS IIS:\> New-Item 'IIS:\Sites\Default Web Site\DemoVirtualDir1' -type VirtualDirectory -physicalPath c:\test\virtualDirectory1