Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASP.NET Core Angular 2 template: Web API method (e.g. WeatherForecasts) called twice on F5 #17

Open
TarasBanakh opened this issue Dec 9, 2016 · 2 comments

Comments

@TarasBanakh
Copy link

TarasBanakh commented Dec 9, 2016

Installed product versions

  • Visual Studio 2015
  • This extension: 1.1.37

Description

In ASP.NET Core Angular 2 template the Web API server method WeatherForecasts called twice on browser refresh (F5) of 'http://localhost:5000/fetch-data' page.

Steps to recreate

  1. Add System.Threading.Thread.Sleep(TimeSpan.FromSeconds(10)); in the beginning of Web API method WeatherForecasts. (Or just set a breakpoint in WeatherForecasts and debug it).
  2. Try to refresh (F5) the 'http://localhost:5000/fetch-data' page.

Current behavior

You will notice that WeatherForecasts is called twice: once on the server during server-side prerendering and once from the browser's javascript after the page has being loaded.

Expected behavior

It should be only called once during server-side prerendering.

@SteveSandersonMS
Copy link
Contributor

This is expected. Unlike the Redux template, the Angular app doesn't have an automatic way to transfer state from server to client.

@freddy01288
Copy link

any help for this? I get initial data twice, does anyone know if this happens only in development and not in production ?, it's a serious problem :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants