title: How to configure IIS Express to debug an application in a subdirectory?
body: <p>My web application is typically located in a subdirectory of the root in IIS.  Suppose the subdirectory is "app"</p>
  
  <p>When I try to debug it in Visual Studio, the path is always rooted at localhost, with no subdirectory.  This messes up my paths in the application.</p>
  
  <p>When I try to change the project URL's form from <code>http://localhost:port/</code> to  <code>http://localhost:port/app</code> it just says "Cannot create virtual directory."  Well, that's what it said the first time, until I removed the application entry from the application.config file, then it succeeded.</p>
  
  <p>When I try the "override application root URL" to the same thing, it just doesn't work.  It either gets an Error 500.0 Internal Server error, or in some cases it acts like it's applying the application's web.config file to both the root and the virtual subdirectory, because it gives an error that I'm trying to add a module that has already been added (presumably in the root).</p>
  
  <p>I've tried editing the project's settings in application.config for IIS Express, but no combination of settings seems to work.</p>
  
  <p>I don't understand why visual studio is situating the project at an IIS Express root directory, when it knows this project is deployed to IIS in a subdirectory.  I think it should match the directory structure by default.</p>
  
  <p>This is what it looks like now:</p>
  
  <pre><code>&lt;site name="app" id="5"&gt;
     &lt;application path="/" applicationPool="Clr4IntegratedAppPool"&gt;
       &lt;virtualDirectory path="/app" physicalPath="C:\Users\username\Desktop\wwwroot\app" /&gt;
     &lt;/application&gt;
     &lt;bindings&gt;
       &lt;binding protocol="http" bindingInformation="*:3056:localhost" /&gt;
     &lt;/bindings&gt;
  &lt;/site&gt;
  </code></pre>
  
  <p>If I change the application path to "/app", then it gives error 500.19, saying the configuration is invalid.  If I do the same thing and remove the virtual directory tag, then it fails to launch IIS Express altogether.</p>