Visual Studio 2017 Angular 6 shows "Cannot Get /" First Try Only

Paul Speranza picture Paul Speranza · Sep 7, 2018 · Viewed 8.8k times · Source

I am using Visual Studio 2017 15.8.3 with .Net Core 2.1 and Angular 6. I used the template to create the project and upgraded it from Angular 5 to 6. It ran as expected. I removed the template code and added my own. As I added more code I started getting the Cannot GET/ message; however, if I go into any .ts file and save it, refresh the browser everything reloads and comes up as expected. No errors ever show. I can't see any issues.

I have this in Startup

    app.UseSpa(spa =>
    {
        // To learn more about options for serving an Angular SPA from ASP.NET Core,
        // see https://go.microsoft.com/fwlink/?linkid=864501

        spa.Options.SourcePath = "ClientApp";

        if (env.IsDevelopment())
        {
            spa.Options.StartupTimeout = new TimeSpan(0, 0, 360);
            spa.UseAngularCliServer(npmScript: "start");
            spa.UseProxyToSpaDevelopmentServer("https://localhost:4200");
        }
    });

I'm stumped.

Thanks, Paul

Answer

Paul Speranza picture Paul Speranza · Sep 7, 2018

Ok so this is kind of embarrassing but I am leaving this here just in case someone runs into the same problem and can't figure it out.

I had copied a bunch of code over from a prototype project and I left out a file that wasn't obvious. How did I find it? The Output window in Visual Studio! None of the other tools showed anything.

Microsoft.AspNetCore.SpaServices:Error: ERROR in src/app/models/user-configuration.model.ts(1,36): error TS2307: Cannot find module './functional-ability.model'.

So I guess the lesson here is this:

  • Cannot GET / seems to be telling you that something is missing

  • The Visual Studio Output window and Error List are your buddies in these, and many other situations.