Reputation: 2709
Got a standard Asp.Net Web core (3.1) Angular Template application. Works fine! Added a put request to the WeatherForecastController (forecasts are in a static List weatherList). Simplified, the request looks like:
[HttpPut("{id}")]
public async Task<IActionResult> PutForecastItem(int id, WeatherForecast item)
{
if (id != item.Id)
{
return BadRequest();
}
var org = weatherList.ElementAt(id);
org.TemperatureC = item.TemperatureC;
return NoContent();
}
Calling this method (VS2019 debug) error 500 is generated: Http failure response for https://localhost:44345//weatherforecast/1: 500 OK System.Net.Http.HttpRequestException: Failed to proxy the request to http://weatherforecast/1, because the request to the proxy target failed.
How to fix this? Thanks for any help!
Upvotes: 0
Views: 2056
Reputation: 2709
The problem was caused by an extra forward slash:
ngOnInit() {
this.http.get<WeatherForecast[]>(`${this.baseUrl}**/**weatherforecast`)
.subscribe(result => {
this.forecasts = result;
}, error => console.error(error));
}
Should be:
ngOnInit() {
this.http.get<WeatherForecast[]>(`${this.baseUrl}weatherforecast`)
.subscribe(result => {
this.forecasts = result;
}, error => console.error(error));
}
Upvotes: 1