Make http client synchronous: wait for response

前端 未结 2 1719
萌比男神i
萌比男神i 2021-01-31 15:59

I have some file to upload and some of the files failed because the post is asynchronous and not synchronous..

I\'m trying to make this call as synchronized call..

2条回答
  •  Happy的楠姐
    2021-01-31 16:26

    change

    await content.ReadAsStringAsync().ConfigureAwait(false)
    

    to

    content.ReadAsStringAsync().Result
    

    the ReadAsStringAsync returns a Task object. the '.Result' in the end of the line tell the compiler to return the inner string.

提交回复
热议问题