title: ASP.NET Core 404 for project template with Angular 6 bundled files (wrong dist output directory)
body: <p>I've created a ASP.NET Core application with the Angular project template <a href="https://docs.microsoft.com/en-US/aspnet/core/client-side/spa/angular?view=aspnetcore-2.1&amp;tabs=visual-studio" rel="noreferrer">https://docs.microsoft.com/en-US/aspnet/core/client-side/spa/angular?view=aspnetcore-2.1&amp;tabs=visual-studio</a></p>
  <h1>Generated output</h1>
  <p>When deploying on IIS, the base href is <code>&lt;base href=&quot;/&quot;&gt;</code></p>
  <p>And the path of the scripts inside the generated dist/index.html are :</p>
  <pre><code>&lt;script type=&quot;text/javascript&quot; src=&quot;runtime.js&quot;&gt;&lt;/script&gt;
  &lt;script type=&quot;text/javascript&quot; src=&quot;polyfills.js&quot;&gt;&lt;/script&gt;
  &lt;script type=&quot;text/javascript&quot; src=&quot;vendor.js&quot;&gt;&lt;/script&gt;
  &lt;script type=&quot;text/javascript&quot; src=&quot;main.js&quot;&gt;&lt;/script&gt;
  </code></pre>
  <h1>Problem : 404 errors</h1>
  <p><a href="https://i.stack.imgur.com/NH1E0.png" rel="noreferrer"><img src="https://i.stack.imgur.com/NH1E0.png" alt="Screenshot of the 404 when deployed on IIS" /></a></p>
  <h1>However C# Startup.cs should correctly set the path to the output directory</h1>
  <p>The ASP.NET Core project should be aware that these files are in the <code>ClientApp/dist</code> directory because of this code :</p>
  <pre><code>    public void ConfigureServices(IServiceCollection services)
      {
          services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
  
          // In production, the Angular files will be served from this directory
          services.AddSpaStaticFiles(configuration =&gt;
          {
              configuration.RootPath = &quot;ClientApp/dist&quot;;
          });
      }
  </code></pre>
  <h1>Why the base path isn't set correctly ?</h1>
  <p>The project runs on IIS, we can see the background initialisation message of index.html appear correctly, however as shown in the picture, all resources are loaded on the root &quot;/&quot; of the server, so they get 404's.</p>
  <p>If I try to load http://{SERVERIP}/{PROJECTNAMEHERE}/runtime.js I see that it works, so I guess that it's probably only a matter of <strong>base href</strong>.</p>
  <p>How to set that base href dynamically from ASP.NET Core?</p>