Asp.net web api 我必须与HttpClient一起使用ContinueWith吗?

Asp.net web api 我必须与HttpClient一起使用ContinueWith吗?,asp.net-web-api,dotnet-httpclient,Asp.net Web Api,Dotnet Httpclient,当使用System.Net.Http.HttpClient调用rest服务时,我有如下代码 var response = client.GetAsync("api/MyController").Result; if(response.IsSuccessStatusCode) ... 这是正确的还是我应该这样做 client.GetAsync("api/MyController").ContinueWith(task => { var response = task.Result; ...

当使用System.Net.Http.HttpClient调用rest服务时,我有如下代码

var response = client.GetAsync("api/MyController").Result;
if(response.IsSuccessStatusCode)
...
这是正确的还是我应该这样做

client.GetAsync("api/MyController").ContinueWith(task => { var response = task.Result; ...}

做第二件事要安全得多。有多种情况下,第一个选项可能会导致死锁