Creating virtual directories in IIS express
Solution 1:
IIS express configuration is managed by applicationhost.config.
You can find it in
Users\<username>\Documents\IISExpress\config folder.
Inside you can find the sites section that hold a section for each IIS Express configured site.
Add (or modify) a site section like this:
<site name="WebSiteWithVirtualDirectory" id="20">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="c:\temp\website1" />
</application>
<application path="/OffSiteStuff" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="d:\temp\SubFolderApp" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:1132:localhost" />
</bindings>
</site>
Practically you need to add a new application tag in your site for each virtual directory. You get a lot of flexibility because you can set different configuration for the virtual directory (for example a different .Net Framework version)
EDIT Thanks to Fevzi Apaydın to point to a more elegant solution.
You can achieve same result by adding one or more virtualDirectory tag to the Application tag:
<site name="WebSiteWithVirtualDirectory" id="20">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="c:\temp\website1" />
<virtualDirectory path="/OffSiteStuff" physicalPath="d:\temp\SubFolderApp" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:1132:localhost" />
</bindings>
</site>
Reference:
- Application tag for a Site
- Virtual Directory tag
Solution 2:
@Be.St.'s aprroach is true, but incomplete. I'm just copying his explanation with correcting the incorrect part.
IIS express configuration is managed by applicationhost.config.
You can find it in
Users\<username>\Documents\IISExpress\config folder.
Inside you can find the sites section that hold a section for each IIS Express configured site.
Add (or modify) a site section like this:
<site name="WebSiteWithVirtualDirectory" id="20">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="c:\temp\website1" />
<virtualDirectory path="/OffSiteStuff" physicalPath="d:\temp\SubFolderApp" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:1132:localhost" />
</bindings>
</site>
Instead of adding a new application block, you should just add a new virtualDirectory element to the application parent element.
Edit - Visual Studio 2015
If you're looking for the applicationHost.config file and you're using VS2015 you'll find it in:
[solution_directory]/.vs/config/applicationHost.config
Solution 3:
In VS2013 I did this in the following steps:
1.Right-click the web application project and hit Properties
2.View the "Web" tab of the Properties page
3.Under Servers, with "IIS Express" being the default choice of the dropdown, in the "Project Url" change the url using the port number to one that suits you. For example I deleted the port number and added "/MVCDemo4" after the localhost.
4.Click the "Create Virtual Directory" button.
5.Run your project and the new url will be used