use*_*476 6 c# async-await dotnet-httpclient
我是HttpClient的新手.我的代码总是在状态中显示"WaitingForActivation".请帮忙
private static async Task<HttpResponseMessage> MakeCall()
{
var httpclient = new HttpClient();
var response = await httpclient.GetAsync("http://localhost:60565/Subscribers");
return response;
}
Run Code Online (Sandbox Code Playgroud)
或者,如果您的环境是同步添加.Result,如下所示:
GetAsync("http://localhost:60565/Subscribers").Result;
Run Code Online (Sandbox Code Playgroud)