Visual Studio with ASP-NET and Angular show TimeoutException in Browser

Viewed 2703

When staring debug after 60 sec waiting this shows in the browser. Refreshing the browser window and 15 sec later everything works ok

An unhandled exception occurred while processing the request. TimeoutException: The Angular CLI process did not start listening for requests within the timeout period of 50 seconds. Check the log output for error information.

Any idea?

3 Answers

That is because the angular CLI is not bootstrap fast enough so to fix it you have 2 options

Increase a time out in Startup.cs

app.UseSpa(spa =>
    {
        spa.Options.SourcePath = "ClientApp";

        if (env.IsDevelopment())
        {
            spa.Options.StartupTimeout = new TimeSpan(0, 0, 80); // 80 seconds
            spa.UseAngularCliServer(npmScript: "start");
        }
    });

or navigate to ClientApp folder run ng serve and wait for compilation process is done so you can run your project again

Update: I find the way to resolve this error is running dotnet run in the cmd

For development purpose if you are getting the error as 'TimeoutException: The Angular CLI process did not start listening for requests within the timeout period of 0 seconds.' .

Please follow these 2 steps which work for me as well :

  1. In command prompt, Run the 'ng serve' command to run the angular solution.
  2. In startup.cs file, change the start up timeout to minutes. even it will not take that much of time as angular solution is already running.

-> spa.Options.StartupTimeout = new TimeSpan(0, 5, 0);

Please mark the answer if it helps you !!

Thanks.

Related