After creating a default Blazor app (V0.5.1) we get a FetchData.cshtml page which gets its data from a local .json file
@functions {
WeatherForecast[] forecasts;
protected override async Task OnInitAsync()
{
forecasts = await Http.GetJsonAsync<WeatherForecast[]>("sample-data/weather.json");
}
class WeatherForecast
{
public DateTime Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF { get; set; }
public string Summary { get; set; }
}
}
This works fine. However, if change this to get the same data from a .net core rest web api the call to Http.GetJsonAsync
hangs. There's no error it just never completes.
protected override async Task OnInitAsync()
{
forecasts = await Http.GetJsonAsync<WeatherForecast[]>(
"http://localhost:5000/api/weatherforecast/");
}
What am I missing?