HttpResponseMessage' does not contain a definition for 'GetAwaiter' and no accessible extension method 'GetAwaiter'
问题 I have this xUnit method in C# which test a web api [Fact] public async Task GetWeatherForecast() { var apiClient = new HttpClient(); var apiResponse = await apiClient.GetAsync($"http://xxx/weatherforecast").Result; Assert.True(apiResponse.IsSuccessStatusCode); } But hit this error HttpResponseMessage' does not contain a definition for 'GetAwaiter' and no accessible extension method 'GetAwaiter' . If I removed async Task and await , it could run successfully. 回答1: Don't call Result , it's