Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 427
Paul Speranza Avatar asked Sep 07 '18 15:09

Paul Speranza


3 Answers

I'm on the same page and I found my problem with ng build command, You should try that, Probably you find it.

like image 117
Saeid Mirzaei Avatar answered Oct 26 '22 09:10

Saeid Mirzaei


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.

like image 45
Paul Speranza Avatar answered Oct 26 '22 09:10

Paul Speranza


I had a similar problem. The reason was I used '#' in a project path.

like image 38
Vladimir Genesis Avatar answered Oct 26 '22 08:10

Vladimir Genesis